class Translation::TranslationRecognizer

class Translation::TranslationRecognizer
  : public AsyncRecognizer< TranslationRecognitionResult, TranslationRecognitionEventArgs, TranslationRecognitionCanceledEventArgs >

Performs translation on the speech input.

Members

Properties

Syntax: public PropertyCollection & Properties;

The collection of properties and their values defined for this TranslationRecognizer.

Synthesizing

Syntax: public EventSignal< const TranslationSynthesisEventArgs & > Synthesizing;

The event signals that a translation synthesis result is received.

TranslationRecognizer

Syntax: public inline explicit TranslationRecognizer ( SPXRECOHANDLE hreco );

It is intended for internal use only. It creates an instance of TranslationRecognizer.

It is recommended to use SpeechTranslationConfig to create an instance of TranslationRecognizer. This method is mainly used in case where a recognizer handle has been created by methods via C-API.

Parameters

  • hreco The handle of the recognizer that is returned by C-API.

~TranslationRecognizer

Syntax: public inline ~TranslationRecognizer ( );

Deconstruct the instance.

RecognizeOnceAsync

Syntax: public inline virtual std::future< std::shared_ptr< TranslationRecognitionResult > > RecognizeOnceAsync ( );

Starts translation 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 recognized text as well as the translation. 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

An asynchronous operation representing the recognition. It returns a value of TranslationRecognitionResult as result.

StartContinuousRecognitionAsync

Syntax: public inline virtual std::future< void > StartContinuousRecognitionAsync ( );

Starts translation on a continous audio stream, until StopContinuousRecognitionAsync() is called. User must subscribe to events to receive recognition results.

Returns

An asynchronous operation that starts the translation.

StopContinuousRecognitionAsync

Syntax: public inline virtual std::future< void > StopContinuousRecognitionAsync ( );

Stops continuous translation.

Returns

A task representing the asynchronous operation that stops the translation.

StartKeywordRecognitionAsync

Syntax: public inline virtual std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );

Starts keyword recognition on a continuous audio stream, until StopKeywordRecognitionAsync() is called.

Note: Keyword spotting (KWS) functionality might work with any microphone type, official KWS support, however, is currently limited to the microphone arrays found in the Azure Kinect DK hardware or the Speech Devices SDK.

Parameters

  • model Specifies the keyword model to be used.

Returns

An asynchronous operation that starts the keyword recognition.

StopKeywordRecognitionAsync

Syntax: public inline virtual std::future< void > StopKeywordRecognitionAsync ( );

Stops continuous keyword recognition.

Note: Keyword spotting (KWS) functionality might work with any microphone type, official KWS support, however, is currently limited to the microphone arrays found in the Azure Kinect DK hardware or the Speech Devices SDK.

Returns

A task representing the asynchronous operation that stops the keyword 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 A string that represents the endpoint id.

GetAuthorizationToken

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

Gets the authorization token.

Returns

Authorization token

AddTargetLanguage

Syntax: public inline void AddTargetLanguage ( const std::string & language );

Adds a target language for translation. Added in version 1.7.0.

Parameters

  • language Translation target language to add.

RemoveTargetLanguage

Syntax: public inline void RemoveTargetLanguage ( const std::string & language );

Removes a target language for translation. Added in version 1.7.0.

Parameters

  • language Translation target language to remove.

GetTargetLanguages

Syntax: public inline std::vector< std::string > GetTargetLanguages ( ) const;

Gets target languages for translation. Added in version 1.7.0.

Returns

Vector of translation target languages.

FromConfig

Syntax: public inline static std::shared_ptr< TranslationRecognizer > FromConfig ( std::shared_ptr< SpeechTranslationConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioInput );

Create a translation recognizer from a translation config and an audio config. Users should use this function to create a translation recognizer.

Parameters

  • speechconfig Speech translation config.

  • audioInput Audio config.

Returns

The shared smart pointer of the created translation recognizer.

BaseType

Syntax: typedef BaseType;