TranslationRecognizer class
Translation recognizer
- Extends
Constructors
Translation |
Initializes an instance of the TranslationRecognizer. |
Properties
authorization |
Gets the authorization token used to communicate with the service. |
canceled | The event canceled signals that an error occurred during recognition. |
internal |
|
properties | The collection of properties and their values defined for this TranslationRecognizer. |
recognized | The event recognized signals that a final recognition result is received. |
recognizing | The event recognizing signals that an intermediate recognition result is received. |
speech |
Gets the language name that was set when the recognizer was created. |
synthesizing | The event synthesizing signals that a translation synthesis result is received. |
target |
Gets target languages for translation that were set when the recognizer was created. The language is specified in BCP-47 format. The translation will provide translated text for each of language. |
telemetry |
This method returns the current state of the telemetry setting. |
voice |
Gets the name of output voice. |
Inherited Properties
session |
Defines event handler for session started events. |
session |
Defines event handler for session stopped events. |
speech |
Defines event handler for speech stopped events. |
speech |
Defines event handler for speech started events. |
Methods
add |
dynamically add a language to list of target language (can be used while recognition is ongoing) |
close(() => void, (error: string) => void) | closes all external resources held by an instance of this class. |
From |
TranslationRecognizer constructor. |
on |
handles ConnectionEstablishedEvent for conversation translation scenarios. |
recognize |
Starts recognition and translation, and stops after the first utterance is recognized. The task returns the translation text as result. Note: recognizeOnceAsync returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use startContinuousRecognitionAsync() instead. |
remove |
dynamically remove a language from list of target language (can be used while recognition is ongoing) |
start |
Starts recognition and translation, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive translation results. |
stop |
Stops continuous recognition and translation. |
Inherited Methods
enable |
This method globally enables or disables telemetry. |
Constructor Details
TranslationRecognizer(SpeechTranslationConfig, AudioConfig, IConnectionFactory)
Initializes an instance of the TranslationRecognizer.
new TranslationRecognizer(speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig, connectionFactory?: IConnectionFactory)
Parameters
- speechConfig
- SpeechTranslationConfig
Set of properties to configure this recognizer.
- audioConfig
- AudioConfig
An optional audio config associated with the recognizer
- connectionFactory
-
IConnectionFactory
An optional connection factory to use to generate the endpoint URIs, headers to set, etc...
Property Details
authorizationToken
Gets the authorization token used to communicate with the service.
string authorizationToken
Property Value
string
Authorization token.
canceled
The event canceled signals that an error occurred during recognition.
public canceled: (sender: TranslationRecognizer, event: TranslationRecognitionCanceledEventArgs) => void
Property Value
(sender: TranslationRecognizer, event: TranslationRecognitionCanceledEventArgs) => void
internalData
object internalData
Property Value
object
properties
The collection of properties and their values defined for this TranslationRecognizer.
PropertyCollection properties
Property Value
The collection of properties and their values defined for this TranslationRecognizer.
recognized
The event recognized signals that a final recognition result is received.
public recognized: (sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void
Property Value
(sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void
recognizing
The event recognizing signals that an intermediate recognition result is received.
public recognizing: (sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void
Property Value
(sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void
speechRecognitionLanguage
Gets the language name that was set when the recognizer was created.
string speechRecognitionLanguage
Property Value
string
Gets the language name that was set when the recognizer was created.
synthesizing
The event synthesizing signals that a translation synthesis result is received.
public synthesizing: (sender: TranslationRecognizer, event: TranslationSynthesisEventArgs) => void
Property Value
(sender: TranslationRecognizer, event: TranslationSynthesisEventArgs) => void
targetLanguages
Gets target languages for translation that were set when the recognizer was created. The language is specified in BCP-47 format. The translation will provide translated text for each of language.
string[] targetLanguages
Property Value
string[]
Gets target languages for translation that were set when the recognizer was created.
telemetryEnabled
This method returns the current state of the telemetry setting.
static boolean telemetryEnabled
Property Value
boolean
true if the telemetry is enabled, false otherwise.
voiceName
Gets the name of output voice.
string voiceName
Property Value
string
the name of output voice.
Inherited Property Details
sessionStarted
Defines event handler for session started events.
public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void
Property Value
(sender: Recognizer, event: SessionEventArgs) => void
Inherited From Recognizer.sessionStarted
sessionStopped
Defines event handler for session stopped events.
public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void
Property Value
(sender: Recognizer, event: SessionEventArgs) => void
Inherited From Recognizer.sessionStopped
speechEndDetected
Defines event handler for speech stopped events.
public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void
Property Value
(sender: Recognizer, event: RecognitionEventArgs) => void
Inherited From Recognizer.speechEndDetected
speechStartDetected
Defines event handler for speech started events.
public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void
Property Value
(sender: Recognizer, event: RecognitionEventArgs) => void
Inherited From Recognizer.speechStartDetected
Method Details
addTargetLanguage(string)
dynamically add a language to list of target language (can be used while recognition is ongoing)
function addTargetLanguage(lang: string)
Parameters
- lang
-
string
language to be added
close(() => void, (error: string) => void)
closes all external resources held by an instance of this class.
function close(cb?: () => void, errorCb?: (error: string) => void)
Parameters
- cb
-
() => void
- errorCb
-
(error: string) => void
FromConfig(SpeechTranslationConfig, AutoDetectSourceLanguageConfig, AudioConfig)
TranslationRecognizer constructor.
static function FromConfig(speechTranslationConfig: SpeechTranslationConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): TranslationRecognizer
Parameters
- speechTranslationConfig
- SpeechTranslationConfig
an set of initial properties for this recognizer
- autoDetectSourceLanguageConfig
- AutoDetectSourceLanguageConfig
An source language detection configuration associated with the recognizer
- audioConfig
- AudioConfig
An optional audio configuration associated with the recognizer
Returns
onConnection()
handles ConnectionEstablishedEvent for conversation translation scenarios.
function onConnection()
recognizeOnceAsync((e: TranslationRecognitionResult) => void, (e: string) => void)
Starts recognition and translation, and stops after the first utterance is recognized. The task returns the translation text as result. Note: recognizeOnceAsync returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use startContinuousRecognitionAsync() instead.
function recognizeOnceAsync(cb?: (e: TranslationRecognitionResult) => void, err?: (e: string) => void)
Parameters
- cb
-
(e: TranslationRecognitionResult) => void
Callback that received the result when the translation has completed.
- err
-
(e: string) => void
Callback invoked in case of an error.
removeTargetLanguage(string)
dynamically remove a language from list of target language (can be used while recognition is ongoing)
function removeTargetLanguage(lang: string)
Parameters
- lang
-
string
language to be removed
startContinuousRecognitionAsync(() => void, (e: string) => void)
Starts recognition and translation, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive translation results.
function startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)
Parameters
- cb
-
() => void
Callback that received the translation has started.
- err
-
(e: string) => void
Callback invoked in case of an error.
stopContinuousRecognitionAsync(() => void, (e: string) => void)
Stops continuous recognition and translation.
function stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)
Parameters
- cb
-
() => void
Callback that received the translation has stopped.
- err
-
(e: string) => void
Callback invoked in case of an error.
Inherited Method Details
enableTelemetry(boolean)
This method globally enables or disables telemetry.
static function enableTelemetry(enabled: boolean)
Parameters
- enabled
-
boolean
Global setting for telemetry collection. If set to true, telemetry information like microphone errors, recognition errors are collected and sent to Microsoft. If set to false, no telemetry is sent to Microsoft.
Inherited From Recognizer.enableTelemetry