SpeechRecognizer Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Enables speech recognition with either a default or a custom graphical user interface (GUI).
public ref class SpeechRecognizer sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Media.SpeechRecognition.ISpeechRecognizerFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class SpeechRecognizer final : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Media.SpeechRecognition.ISpeechRecognizerFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class SpeechRecognizer final : IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Media.SpeechRecognition.ISpeechRecognizerFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class SpeechRecognizer : System.IDisposable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Media.SpeechRecognition.ISpeechRecognizerFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class SpeechRecognizer : System.IDisposable
function SpeechRecognizer(language)
Public NotInheritable Class SpeechRecognizer
Implements IDisposable
- Inheritance
- Attributes
- Implements
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Remarks
CompileConstraintsAsync must always be called before RecognizeAsync or RecognizeWithUIAsync, even if no constraints are specified in the Constraints property.
Version history
Windows version | SDK version | Value added |
---|---|---|
1709 | 16299 | TrySetSystemSpeechLanguageAsync |
Constructors
SpeechRecognizer() |
Creates a new instance of the SpeechRecognizer class. |
SpeechRecognizer(Language) |
Creates a new instance of the SpeechRecognizer class with a language specifier. |
Properties
Constraints |
Gets the collection of constraint objects currently added to the SpeechRecognizer object. |
ContinuousRecognitionSession |
Gets the continuous recognition session object (SpeechContinuousRecognitionSession) associated with this SpeechRecognizer. |
CurrentLanguage |
Gets the language used for speech recognition. |
State |
Gets the state of the speech recognizer. |
SupportedGrammarLanguages |
Gets the collection of languages supported by the custom grammars of the SpeechRecognitionGrammarFileConstraint and SpeechRecognitionListConstraint objects specified in the Constraints property. |
SupportedTopicLanguages |
Gets the collection of languages supported by the pre-defined, web-service grammars of the SpeechRecognitionTopicConstraint objects specified in the Constraints property. |
SystemSpeechLanguage |
Gets the speech language of the device specified in Settings > Time & Language > Speech. |
Timeouts |
Gets how long a speech recognizer ignores silence or unrecognizable sounds (babble) and continues listening for speech input. |
UIOptions |
Gets the UI settings for the RecognizeWithUIAsync method. |
Methods
Close() |
Disposes the speech recognizer by freeing, releasing, or resetting allocated resources. |
CompileConstraintsAsync() |
Asynchronously compile all constraints specified by the Constraints property. |
Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
RecognizeAsync() |
Begins a speech recognition session for a SpeechRecognizer object. |
RecognizeWithUIAsync() |
Asynchronously starts a speech recognition session that includes additional UI mechanisms, including prompts, examples, text-to-speech (TTS), and confirmations. |
StopRecognitionAsync() |
Asynchronously ends the speech recognition session. |
TrySetSystemSpeechLanguageAsync(Language) |
Asynchronously attempts to set the system language used for speech recognition on an IoT device. Note This method is available only in Embedded mode. |
Events
HypothesisGenerated |
Occurs during an ongoing dictation session when a recognition result fragment is returned by the speech recognizer. |
RecognitionQualityDegrading |
This event is raised when an audio problem is detected that might affect recognition accuracy. |
StateChanged |
This event is raised when a change occurs to the State property during audio capture. |