class SourceLanguageRecognizer

class SourceLanguageRecognizer
  : public AsyncRecognizer< SpeechRecognitionResult, SpeechRecognitionEventArgs, SpeechRecognitionCanceledEventArgs >

Class for source language recognizers. You can use this class for standalone language detection. Added in version 1.17.0.

Members

Properties

Syntax: public PropertyCollection & Properties;

A collection of properties and their values defined for this SourceLanguageRecognizer.

SourceLanguageRecognizer

Syntax: public inline explicit SourceLanguageRecognizer ( SPXRECOHANDLE hreco );

Internal constructor. Creates a new instance using the provided handle.

Parameters

  • hreco Recognizer handle.

~SourceLanguageRecognizer

Syntax: public inline ~SourceLanguageRecognizer ( );

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< SourceLanguageRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioInput );

Create a source language recognizer from a speech config, auto detection source language config and audio config.

Parameters

  • speechconfig Speech configuration

  • autoDetectSourceLangConfig Auto detection source language config

  • audioInput Audio configuration

Returns

A smart pointer wrapped source language recognizer pointer.

BaseType

Syntax: typedef BaseType;