DictationGrammar.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Recognition / DictationGrammar.cs / 1 / DictationGrammar.cs

                            //---------------------------------------------------------------------------- 
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//--------------------------------------------------------------------------- 

#if !SPEECHSERVER 
 
using System;
using System.Diagnostics; 

namespace System.Speech.Recognition
{
    // Class for grammars based on a statistical language model for doing dictation. 
    /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar"]/*' />
 
    public class DictationGrammar: Grammar 
    {
        // The implementation of DictationGrammar stores a Uri in the Grammar.Uri field. 
        // Then when LoadGrammar is called the Uri handling part of LoadGrammar is modified to check
        // if the grammar object is a DictationGrammar, in which case the SAPI dictation methods are called.
        // The Uri is "grammar:dictation" for regular dictation and "grammar:dictation#spelling" for a spelling.
 
        //*******************************************************************
        // 
        // Constructors 
        //
        //******************************************************************* 

        #region Constructors

        // Load the generic dictation language model. 
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.DictationGrammar1"]/*' />
        public DictationGrammar() : base(_defaultDictationUri, null, null) 
        { 
        }
 
        // Load a specific topic. The topic is of the form "grammar:dictation#topic"
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.DictationGrammar2"]/*' />
        public DictationGrammar(string topic) : base (new Uri(topic, UriKind.RelativeOrAbsolute), null, null)
        { 
        }
 
        #endregion 

 

        //********************************************************************
        //
        // Public Methods 
        //
        //******************************************************************* 
 
        #region Public Methods
 
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.SetDictationContext"]/*' />
        public void SetDictationContext(string precedingText, string subsequentText)
        {
            if (State != GrammarState.Loaded) 
            {
                throw new InvalidOperationException(SR.Get(SRID.GrammarNotLoaded)); 
            } 
            // Note: You can only call this method after the Grammar is Loaded.
            // In theory we could support this more generally but there doesn't seem to be a lot of point. 
            Debug.Assert(Recognizer != null);

            Recognizer.SetDictationContext(this, precedingText, subsequentText);
        } 

        #endregion 
 

 
        //********************************************************************
        //
        // Internal Methods
        // 
        //********************************************************************
 
        #region Internal Methods 

 
        #endregion


 
        //*******************************************************************
        // 
        // Private Fields 
        //
        //******************************************************************** 

        #region Private Fields

        private static Uri _defaultDictationUri = new Uri("grammar:dictation"); 

        #endregion 
 
    }
} 

#endif

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------- 
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//--------------------------------------------------------------------------- 

#if !SPEECHSERVER 
 
using System;
using System.Diagnostics; 

namespace System.Speech.Recognition
{
    // Class for grammars based on a statistical language model for doing dictation. 
    /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar"]/*' />
 
    public class DictationGrammar: Grammar 
    {
        // The implementation of DictationGrammar stores a Uri in the Grammar.Uri field. 
        // Then when LoadGrammar is called the Uri handling part of LoadGrammar is modified to check
        // if the grammar object is a DictationGrammar, in which case the SAPI dictation methods are called.
        // The Uri is "grammar:dictation" for regular dictation and "grammar:dictation#spelling" for a spelling.
 
        //*******************************************************************
        // 
        // Constructors 
        //
        //******************************************************************* 

        #region Constructors

        // Load the generic dictation language model. 
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.DictationGrammar1"]/*' />
        public DictationGrammar() : base(_defaultDictationUri, null, null) 
        { 
        }
 
        // Load a specific topic. The topic is of the form "grammar:dictation#topic"
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.DictationGrammar2"]/*' />
        public DictationGrammar(string topic) : base (new Uri(topic, UriKind.RelativeOrAbsolute), null, null)
        { 
        }
 
        #endregion 

 

        //********************************************************************
        //
        // Public Methods 
        //
        //******************************************************************* 
 
        #region Public Methods
 
        /// TODOC <_include file='doc\DictationGrammar.uex' path='docs/doc[@for="DictationGrammar.SetDictationContext"]/*' />
        public void SetDictationContext(string precedingText, string subsequentText)
        {
            if (State != GrammarState.Loaded) 
            {
                throw new InvalidOperationException(SR.Get(SRID.GrammarNotLoaded)); 
            } 
            // Note: You can only call this method after the Grammar is Loaded.
            // In theory we could support this more generally but there doesn't seem to be a lot of point. 
            Debug.Assert(Recognizer != null);

            Recognizer.SetDictationContext(this, precedingText, subsequentText);
        } 

        #endregion 
 

 
        //********************************************************************
        //
        // Internal Methods
        // 
        //********************************************************************
 
        #region Internal Methods 

 
        #endregion


 
        //*******************************************************************
        // 
        // Private Fields 
        //
        //******************************************************************** 

        #region Private Fields

        private static Uri _defaultDictationUri = new Uri("grammar:dictation"); 

        #endregion 
 
    }
} 

#endif

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK