class SpeechRecognizer

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

  • hreco Recognizer 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 15 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

  • model Specifies 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

  • token The authorization token.

GetAuthorizationToken

Syntax: public inline std::string GetAuthorizationToken ( );

Gets the authorization token.

Returns

Authorization token

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

  • speechconfig Speech 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

  • speechConfig Embedded 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

  • speechConfig Hybrid 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

  • speechconfig Speech configuration.

  • audioInput Audio 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

  • speechConfig Embedded speech configuration.

  • audioConfig Audio 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

  • speechConfig Hybrid speech configuration.

  • audioConfig Audio 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

  • speechconfig Speech configuration.

  • autoDetectSourceLangConfig Auto detection source language config.

  • audioInput Audio 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

  • speechconfig Embedded speech configuration.

  • autoDetectSourceLangConfig Auto detection source language config.

  • audioInput Audio 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

  • speechconfig Hybrid speech configuration.

  • autoDetectSourceLangConfig Auto detection source language config.

  • audioInput Audio 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

  • speechconfig Speech configuration.

  • sourceLanguageConfig Source language config.

  • audioInput Audio 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

  • speechconfig Speech configuration.

  • sourceLanguage Source language.

  • audioInput Audio configuration.

Returns

A smart pointer wrapped speech recognizer pointer.

BaseType

Syntax: typedef BaseType;