您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

TranslationRecognizer class

Translation recognizer

Extends

Constructors

TranslationRecognizer(SpeechTranslationConfig, AudioConfig)

Initializes an instance of the TranslationRecognizer.

Properties

authorizationToken

Gets the authorization token used to communicate with the service. Gets/Sets the authorization token used to communicate with the service.

canceled

The event canceled signals that an error occurred during recognition.

internalData
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.

sessionStarted

Defines event handler for session started events.

sessionStopped

Defines event handler for session stopped events.

speechEndDetected

Defines event handler for speech stopped events.

speechRecognitionLanguage

Gets the language name that was set when the recognizer was created.

speechStartDetected

Defines event handler for speech started events.

synthesizing

The event synthesizing signals that a translation synthesis result is received.

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.

telemetryEnabled

This method returns the current state of the telemetry setting.

voiceName

Gets the name of output voice.

Methods

close(() => void, (error: string) => void)

closes all external resources held by an instance of this class.

enableTelemetry(boolean)

This method globally enables or disables telemetry.

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 suitableonly for single shot recognition like command or query. For long-running recognition, use startContinuousRecognitionAsync() instead.

startContinuousRecognitionAsync(() => void, (e: string) => void)

Starts recognition and translation, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive translation results.

stopContinuousRecognitionAsync(() => void, (e: string) => void)

Stops continuous recognition and translation.

Constructor Details

TranslationRecognizer(SpeechTranslationConfig, AudioConfig)

Initializes an instance of the TranslationRecognizer.

new TranslationRecognizer(speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig)

Parameters

speechConfig
SpeechTranslationConfig

Set of properties to configure this recognizer.

audioConfig
AudioConfig

An optional audio config associated with the recognizer

Property Details

authorizationToken

Gets the authorization token used to communicate with the service. Gets/Sets 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

sessionStarted

Defines event handler for session started events.

public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

sessionStopped

Defines event handler for session stopped events.

public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

speechEndDetected

Defines event handler for speech stopped events.

public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => 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.

speechStartDetected

Defines event handler for speech started events.

public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => void

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.

Method Details

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

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.

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 suitableonly 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.

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.