TranslationRecognizer Class

Definition

Performs translation on the speech input. Note: close() must be called in order to release underlying resources held by the object.

public class TranslationRecognizer extends Recognizer
Inheritance
java.lang.Object
AutoCloseable
TranslationRecognizer

Inherited Members

Constructors

TranslationRecognizer(com.microsoft.cognitiveservices.speech.translation.SpeechTranslationConfig stc)

Constructs an instance of a translation recognizer.

TranslationRecognizer(com.microsoft.cognitiveservices.speech.translation.SpeechTranslationConfig stc, AudioConfig audioConfig)

Constructs an instance of a translation recognizer.

Fields

canceled

The event canceled signals that the recognition/translation was canceled.

recognized

The event recognized signals that a final recognition result is received.

recognizing

The event recognizing signals that an intermediate recognition result is received.

synthesizing

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

Methods

addTargetLanguage(String value)

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

getAuthorizationToken()

Gets the authorization token used to communicate with the service.

getProperties()

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

getSpeechRecognitionLanguage()

Gets the spoken language of recognition.

getTargetLanguages()

Gets all target languages that have been configured for translation.

getVoiceName()

Gets the name of output voice.

recognizeOnceAsync()

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.

removeTargetLanguage(String value)

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

setAuthorizationToken(String token)

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

startContinuousRecognitionAsync()

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

stopContinuousRecognitionAsync()

Stops a running recognition operation as soon as possible and immediately requests a result based on the the input that has been processed so far. This works for all recognition operations, not just continuous ones, and facilitates the use of push-to-talk or "finish now" buttons for manual audio endpointing.

Applies to