System.Speech.Recognition Namespace

System.Speech.Recognition 命名空间包含用于实现语音识别的 Windows 桌面语音技术类型。 The System.Speech.Recognition namespace contains Windows Desktop Speech technology types for implementing speech recognition.


SpeechRecognizerSpeechRecognitionEngine 类的 AudioLevelUpdated 事件提供数据。Provides data for the AudioLevelUpdated event of the SpeechRecognizer or the SpeechRecognitionEngine class.


提供 SpeechRecognizerSpeechRecognitionEngineAudioSignalProblemOccurred 事件的相关数据。Provides data for the AudioSignalProblemOccurred event of a SpeechRecognizer or a SpeechRecognitionEngine.


SpeechRecognizerSpeechRecognitionEngine 类的 AudioStateChanged 事件提供数据。Provides data for the AudioStateChanged event of the SpeechRecognizer or the SpeechRecognitionEngine class.


表示一组在语音识别语法约束的选择。Represents a set of alternatives in the constraints of a speech recognition grammar.


表示用于自由文本口述的语音识别语法。Represents a speech recognition grammar used for free text dictation.


SpeechRecognizerSpeechRecognitionEngine 类的 EmulateRecognizeCompleted 事件提供数据。Provides data for the EmulateRecognizeCompleted event of the SpeechRecognizer and SpeechRecognitionEngine classes.


引用语音识别语法的运行时对象,应用程序可以用之来定义语音识别的约束。A runtime object that references a speech recognition grammar, which an application can use to define the constraints for speech recognition.


提供机制以便以编程方式为语音识别语法生成约束。Provides a mechanism for programmatically building the constraints for a speech recognition grammar.


SpeechRecognizerSpeechRecognitionEngine 对象的 LoadGrammarCompleted 事件提供数据。Provides data for the LoadGrammarCompleted event of a SpeechRecognizer or SpeechRecognitionEngine object.


提供有关语音识别事件的信息。Provides information about speech recognition events.


包含有关由 SpeechRecognitionEngineSpeechRecognizer 实例识别的输入的详细信息。Contains detailed information about input that was recognized by instances of SpeechRecognitionEngine or SpeechRecognizer.


为由 SpeechRecognitionEngineSpeechRecognizer 对象引发的 RecognizeCompleted 事件提供数据。Provides data for the RecognizeCompleted event raised by a SpeechRecognitionEngine or a SpeechRecognizer object.


表示与 RecognitionResult 关联的音频输入。Represents audio input that is associated with a RecognitionResult.


包含由语音识别器生成的有关识别的输入的详细信息。Contains detailed information, generated by the speech recognizer, about the recognized input.


提供可识别的语音的原子单元。Provides the atomic unit of recognized speech.


表示有关 SpeechRecognizerSpeechRecognitionEngine 接口的信息。Represents information about a SpeechRecognizer or SpeechRecognitionEngine instance.


RecognizerUpdateReachedRecognizerUpdateReached 事件返回数据。Returns data from a RecognizerUpdateReached or a RecognizerUpdateReached event.


包含有关在识别结果中执行的语音规范化程序的信息。Contains information about a speech normalization procedure that has been performed on recognition results.


将密匙字符串与 SemanticResultValue 值关联,以定义 SemanticValue 对象。Associates a key string with SemanticResultValue values to define SemanticValue objects.


表示一个语义值和选择性地将该值与语音识别语法的组件关联。Represents a semantic value and optionally associates the value with a component of a speech recognition grammar.


表示已识别的短语的语义组织。Represents the semantic organization of a recognized phrase.


SpeechDetectedSpeechDetected 事件返回数据。Returns data from SpeechDetected or SpeechDetected events.


SpeechHypothesizedSpeechHypothesized 事件返回通知。Returns notification from SpeechHypothesized or SpeechHypothesized events.

此类支持 .NET Framework 基础结构,但不应在应用程序代码中直接使用。This class supports the .NET Framework infrastructure and is not intended to be used directly from application code.


提供访问和管理进程内语音识别引擎。Provides the means to access and manage an in-process speech recognition engine.


提供有关 SpeechRecognitionRejectedSpeechRecognitionRejected 事件的信息。Provides information for the SpeechRecognitionRejected and SpeechRecognitionRejected events.


SpeechRecognizedSpeechRecognizedSpeechRecognized 事件提供信息。Provides information for the SpeechRecognized, SpeechRecognized, and SpeechRecognized events.


提供对在 Windows 桌面上可用的共享语言识别服务的访问。Provides access to the shared speech recognition service available on the Windows desktop.


在语音平台用户界面中显示的标识操作提供文本和状态信息。Provides text and status information on recognition operations to be displayed in the Speech platform user interface.


StateChanged 事件返回数据。Returns data from the StateChanged event.



在转到语音识别引擎的音频信号中包含可能问题列表。Contains a list of possible problems in the audio signal coming in to a speech recognition engine.


音频输入到语音识别引擎包含可能状态列表。Contains a list of possible states for the audio input to a speech recognition engine.


列出 SpeechRecognitionEngine 可用于为显示单词或标点符号指定空白的选项。Lists the options that the SpeechRecognitionEngine object can use to specify white space for the display of a word or punctuation mark.


枚举识别模式的值。Enumerates values of the recognition mode.


枚举识别器状态的值。Enumerates values of the recognizer's state.


枚举匹配模式的子集值。Enumerates values of subset matching mode.


Windows 桌面语音技术软件提供了一个基本的语音识别基础结构,数字化发出信号,和从音频输入恢复单词和语音元素。The Windows Desktop Speech Technology software offers a basic speech recognition infrastructure that digitizes acoustical signals, and recovers words and speech elements from audio input.

应用程序使用System.Speech.Recognition命名空间访问并扩展此基本语音识别技术,通过定义的算法来标识和对特定的短语或单词模式进行操作和管理此语音的运行时行为基础结构。Applications use the System.Speech.Recognition namespace to access and extend this basic speech recognition technology by defining algorithms for identifying and acting on specific phrases or word patterns, and by managing the runtime behavior of this speech infrastructure.

创建语法Create Grammars

创建包含的规则或约束,将定义为有意义的输入的单词和短语将识别您的应用程序的一组的语法。You create grammars, which consist of a set of rules or constraints, to define words and phrases that your application will recognize as meaningful input. 使用的构造函数Grammar类,您可以在运行时从创建 grammar 对象GrammarBuilderSrgsDocument实例,或从文件、 字符串或包含的语法定义的流。Using a constructor for the Grammar class, you can create a grammar object at runtime from GrammarBuilder or SrgsDocument instances, or from a file, a string, or a stream that contains a definition of a grammar.

使用GrammarBuilderChoices类,可以以编程方式创建语法的低到中等复杂性,可用于执行识别为许多常见任务。Using the GrammarBuilder and Choices classes, you can programmatically create grammars of low to medium complexity that can be used to perform recognition for many common scenarios. 若要创建语法以编程方式,符合语音识别语法规范 1.0 (SRGS)并充分利用的 SRGS 创作的灵活性,请使用类型的System.Speech.Recognition.SrgsGrammar命名空间。To create grammars programmatically that conform to the Speech Recognition Grammar Specification 1.0 (SRGS) and take advantage of the authoring flexibility of SRGS, use the types of the System.Speech.Recognition.SrgsGrammar namespace. 此外可以创建 XML 格式 SRGS 语法使用任何文本编辑器,并使用结果创建GrammarBuilderSrgsDocument ,或Grammar对象。You can also create XML-format SRGS grammars using any text editor and use the result to create GrammarBuilder, SrgsDocument , or Grammar objects.

此外,DictationGrammar类提供了特殊处理语法,以支持传统的听写模型。In addition, the DictationGrammar class provides a special-case grammar to support a conventional dictation model.

请参阅创建语法系统语音.NET Framework 编程指南有关详细信息和示例。See Create Grammars in the System Speech Programming Guide for .NET Framework for more information and examples.

管理语音识别引擎Manage Speech Recognition Engines

实例SpeechRecognizerSpeechRecognitionEngine随附Grammar对象提供对 Windows 桌面语音技术的语音识别引擎的主访问权限。Instances of SpeechRecognizer and SpeechRecognitionEngine supplied with Grammar objects provide the primary access to the speech recognition engines of the Windows Desktop Speech Technology.

可以使用SpeechRecognizer类来创建使用语音识别技术提供的 Windows,您可以通过配置的应用程序的客户端控制面板You can use the SpeechRecognizer class to create client applications that use the speech recognition technology provided by Windows, which you can configure through the Control Panel. 此类应用程序通过计算机的默认音频输入机制接受输入。Such applications accept input through a computer's default audio input mechanism.

更好地配置和识别引擎的类型的控制,生成应用程序中使用SpeechRecognitionEngine,这在进程中运行。For more control over the configuration and type of recognition engine, build an application using SpeechRecognitionEngine, which runs in-process. 使用SpeechRecognitionEngine类,可以动态地选择音频输入设备、 文件或流。Using the SpeechRecognitionEngine class, you can also dynamically select audio input from devices, files, or streams.

请参阅初始化和管理语音识别引擎系统语音.NET Framework 编程指南有关详细信息。See Initialize and Manage a Speech Recognition Engine in the System Speech Programming Guide for .NET Framework for more information.

对事件做出响应Respond to Events

SpeechRecognizerSpeechRecognitionEngine对象到语音识别引擎的音频输入的响应中生成事件。SpeechRecognizer and SpeechRecognitionEngine objects generate events in response to audio input to the speech recognition engine. AudioLevelUpdatedAudioSignalProblemOccurredAudioStateChanged以响应传入的信号中的更改引发事件。The AudioLevelUpdated, AudioSignalProblemOccurred, AudioStateChanged events are raised in response to changes in the incoming signal. SpeechDetected语音识别引擎标识为语音的传入音频时将引发事件。The SpeechDetected event is raised when the speech recognition engine identifies incoming audio as speech. 语音识别引擎将引发SpeechRecognized事件时,它与匹配语音输入到一个其加载的语法,并引发SpeechRecognitionRejected时,语音输入不匹配任何其加载的语法。The speech recognition engine raises the SpeechRecognized event when it matches speech input to one of its loaded grammars, and raises the SpeechRecognitionRejected when speech input does not match any of its loaded grammars.

其他类型的事件包括LoadGrammarCompleted时它所加载的语法,语音识别引擎引发的事件。Other types of events include the LoadGrammarCompleted event which a speech recognition engine raises when it has loaded a grammar. StateChanged仅针对SpeechRecognizerWindows 语音识别的状态发生更改时引发事件的类。The StateChanged is exclusive to the SpeechRecognizer class, which raises the event when the state of Windows Speech Recognition changes.

你可以注册语音识别引擎引发的事件通知,并使用创建处理程序EventsArgs与每个事件进行编程应用程序的行为时将引发一个事件关联的类。You can register to be notified for events that the speech recognition engine raises and create handlers using the EventsArgs classes associated with each of these events to program your application's behavior when an event is raised.

请参阅使用语音识别事件系统语音.NET Framework 编程指南有关详细信息。See Using Speech Recognition Events in the System Speech Programming Guide for .NET Framework for more information.