Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
class SpeechRecognizer
: public AsyncRecognizer< SpeechRecognitionResult, SpeechRecognitionEventArgs, SpeechRecognitionCanceledEventArgs >
Class for speech recognizers.
Members
Properties
Syntax: public PropertyCollection & Properties;
A collection of properties and their values defined for this SpeechRecognizer.
SpeechRecognizer
Syntax: public inline explicit SpeechRecognizer ( SPXRECOHANDLE hreco );
Internal constructor. Creates a new instance using the provided handle.
Parameters
hrecoRecognizer handle.
~SpeechRecognizer
Syntax: public inline ~SpeechRecognizer ( );
Destructor.
RecognizeOnceAsync
Syntax: public inline virtual std::future< std::shared_ptr< SpeechRecognitionResult > > RecognizeOnceAsync ( );
Starts speech recognition, and returns after a single utterance is recognized. The end of a single utterance is determined by listening for silence at the end or until a maximum of about 30 seconds of audio is processed. The task returns the recognition text as result. Note: Since RecognizeOnceAsync() returns only a single utterance, it is suitable only for single shot recognition like command or query. For long-running multi-utterance recognition, use StartContinuousRecognitionAsync() instead.
Returns
Future containing result value (a shared pointer to SpeechRecognitionResult) of the asynchronous speech recognition.
StartContinuousRecognitionAsync
Syntax: public inline virtual std::future< void > StartContinuousRecognitionAsync ( );
Asynchronously initiates continuous speech recognition operation.
Returns
An empty future.
StopContinuousRecognitionAsync
Syntax: public inline virtual std::future< void > StopContinuousRecognitionAsync ( );
Asynchronously terminates ongoing continuous speech recognition operation.
Returns
An empty future.
StartKeywordRecognitionAsync
Syntax: public inline virtual std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );
Asynchronously initiates keyword recognition operation.
Parameters
modelSpecifies the keyword model to be used.
Returns
An empty future.
StopKeywordRecognitionAsync
Syntax: public inline virtual std::future< void > StopKeywordRecognitionAsync ( );
Asynchronously terminates keyword recognition operation.
Returns
An empty future.
GetEndpointId
Syntax: public inline std::string GetEndpointId ( );
Gets the endpoint ID of a customized speech model that is used for speech recognition.
Returns
the endpoint ID of a customized speech model that is used for speech recognition
SetAuthorizationToken
Syntax: public inline void SetAuthorizationToken ( const std::string & token );
Sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will encounter errors during recognition.
Parameters
tokenThe authorization token.
GetAuthorizationToken
Syntax: public inline std::string GetAuthorizationToken ( );
Gets the authorization token.
Returns
Authorization token
EnableLegacyDefaultDisconnectSilenceTimeout
Syntax: public inline void EnableLegacyDefaultDisconnectSilenceTimeout ( bool enable );
Enables (or disables) the SDK 1.51 (or older) default behavior for the initial and end (disconnect) silence timeouts during continuous recognition.
When called with parameter true, the SDK does not send the initial silence timeout (IST) or end silence timeout (EST) to the service when they are not explicitly configured, letting the service apply its own defaults. When called with parameter false, the SDK sends a value of 0 to the service for each timeout that is not explicitly configured.
Explicitly configured timeout values are always honored regardless of this flag, and this setting only affects continuous recognition (StartContinuousRecognition); single-shot recognition (RecognizeOnce) is unaffected.
If this method is not called, the SDK behaves as if it were called with parameter true.
Parameters
enabletrue to omit unspecified IST and EST values; false to send 0 for unspecified IST and EST values.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::nullptr_t );
Create a speech recognizer from a speech config.
Parameters
speechconfigSpeech configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechConfig , std::nullptr_t );
Create a speech recognizer from an embedded speech config. Added in version 1.19.0.
Parameters
speechConfigEmbedded speech configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechConfig , std::nullptr_t );
Create a speech recognizer from a hybrid speech config.
Parameters
speechConfigHybrid speech configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from a speech config and audio config.
Parameters
speechconfigSpeech configuration.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioConfig );
Create a speech recognizer from an embedded speech config and audio config. Added in version 1.19.0.
Parameters
speechConfigEmbedded speech configuration.audioConfigAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioConfig );
Create a speech recognizer from a hybrid speech config and audio config.
Parameters
speechConfigHybrid speech configuration.audioConfigAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from a speech config, auto detection source language config and audio config Added in 1.8.0.
Parameters
speechconfigSpeech configuration.autoDetectSourceLangConfigAuto detection source language config.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from an embedded speech config, auto detection source language config and audio config Added in 1.20.0.
Parameters
speechconfigEmbedded speech configuration.autoDetectSourceLangConfigAuto detection source language config.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from a hybrid speech config, auto detection source language config and audio config.
Parameters
speechconfigHybrid speech configuration.autoDetectSourceLangConfigAuto detection source language config.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< SourceLanguageConfig > sourceLanguageConfig , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from a speech config, source language config and audio config Added in 1.8.0.
Parameters
speechconfigSpeech configuration.sourceLanguageConfigSource language config.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , const std::string & sourceLanguage , std::shared_ptr< Audio::AudioConfig > audioInput );
Create a speech recognizer from a speech config, source language and audio config Added in 1.8.0.
Parameters
speechconfigSpeech configuration.sourceLanguageSource language.audioInputAudio configuration.
Returns
A smart pointer wrapped speech recognizer pointer.
BaseType
Syntax: typedef BaseType;