TranslationRecognizer Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. Recognizer - com.
microsoft. cognitiveservices. speech. translation. TranslationRecognizer
- com.
- com.
public final class TranslationRecognizer
extends Recognizer
Performs translation on the speech input. Note: close() must be called in order to release underlying resources held by the object.
Field Summary
Modifier and Type | Field and Description |
---|---|
final
Event |
canceled
The event canceled signals that the recognition/translation was canceled. |
final
Event |
recognized
The event recognized signals that a final recognition result is received. |
final
Event |
recognizing
The event recognizing signals that an intermediate recognition result is received. |
final
Event |
synthesizing
The event synthesizing signals that a translation synthesis result is received. |
Constructor Summary
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
addTargetLanguage(String value)
Adds a target language for translation. |
protected void |
dispose(boolean disposing)
This method performs cleanup of resources. |
java.lang.String |
getAuthorizationToken()
Gets the authorization token used to communicate with the service. |
Property |
getProperties()
The collection of properties and their values defined for this Translation |
java.lang.String |
getSpeechRecognitionLanguage()
Gets the spoken language of recognition. |
java.util.ArrayList<java.lang.String> |
getTargetLanguages()
Gets all target languages that have been configured for translation. |
java.lang.String |
getVoiceName()
Gets the name of output voice. |
java.util.concurrent.Future<Translation |
recognizeOnceAsync()
Starts recognition and translation, and stops after the first utterance is recognized. |
void |
removeTargetLanguage(String value)
Removes a target language for translation. |
void |
setAuthorizationToken(String token)
Sets the authorization token used to communicate with the service. |
java.util.concurrent.Future<java.lang.Void> |
startContinuousRecognitionAsync()
Starts recognition and translation on a continuous audio stream, until Stop |
java.util.concurrent.Future<java.lang.Void> |
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. |
Methods inherited from Recognizer
Methods inherited from java.lang.Object
Field Details
canceled
public final EventHandlerImpl
The event canceled signals that the recognition/translation was canceled.
recognized
public final EventHandlerImpl
The event recognized signals that a final recognition result is received.
recognizing
public final EventHandlerImpl
The event recognizing signals that an intermediate recognition result is received.
synthesizing
public final EventHandlerImpl
The event synthesizing signals that a translation synthesis result is received.
Constructor Details
TranslationRecognizer
public TranslationRecognizer(EmbeddedSpeechConfig embeddedSpeechConfig)
Constructs an instance of a translation recognizer for embedded speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(EmbeddedSpeechConfig embeddedSpeechConfig, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig)
Constructs an instance of a translation recognizer for embedded speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(EmbeddedSpeechConfig embeddedSpeechConfig, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig, AudioConfig audioConfig)
Constructs an instance of a translation recognizer for embedded speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(EmbeddedSpeechConfig embeddedSpeechConfig, AudioConfig audioConfig)
Constructs an instance of a translation recognizer for embedded speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(HybridSpeechConfig hybridSpeechConfig)
Constructs an instance of a translation recognizer for hybrid speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(HybridSpeechConfig hybridSpeechConfig, AudioConfig audioConfig)
Constructs an instance of a translation recognizer for hybrid speech translation.
Parameters:
TranslationRecognizer
public TranslationRecognizer(SpeechTranslationConfig stc)
Constructs an instance of a translation recognizer.
Parameters:
TranslationRecognizer
public TranslationRecognizer(SpeechTranslationConfig stc, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig)
Constructs an instance of a translation recognizer.
Parameters:
TranslationRecognizer
public TranslationRecognizer(SpeechTranslationConfig stc, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig, AudioConfig audioConfig)
Constructs an instance of a translation recognizer.
Parameters:
TranslationRecognizer
public TranslationRecognizer(SpeechTranslationConfig stc, AudioConfig audioConfig)
Constructs an instance of a translation recognizer.
Parameters:
Method Details
addTargetLanguage
public void addTargetLanguage(String value)
Adds a target language for translation. Added in version 1.7.0.
Parameters:
dispose
protected void dispose(boolean disposing)
This method performs cleanup of resources. The Boolean parameter disposing indicates whether the method is called from Dispose (if disposing is true) or from the finalizer (if disposing is false). Derived classes should override this method to dispose resource if needed.
Overrides:
TranslationRecognizer.dispose(boolean disposing)Parameters:
getAuthorizationToken
public String getAuthorizationToken()
Gets the authorization token used to communicate with the service.
Returns:
getProperties
public PropertyCollection getProperties()
The collection of properties and their values defined for this TranslationRecognizer.
Returns:
getSpeechRecognitionLanguage
public String getSpeechRecognitionLanguage()
Gets the spoken language of recognition.
Returns:
getTargetLanguages
public ArrayList
Gets all target languages that have been configured for translation.
Returns:
getVoiceName
public String getVoiceName()
Gets the name of output voice.
Returns:
recognizeOnceAsync
public Future
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.
Returns:
removeTargetLanguage
public void removeTargetLanguage(String value)
Removes a target language for translation. Added in version 1.7.0.
Parameters:
setAuthorizationToken
public void 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.
Parameters:
startContinuousRecognitionAsync
public Future
Starts recognition and translation on a continuous audio stream, until StopContinuousRecognitionAsync() is called. User must subscribe to events to receive translation results.
Returns:
stopContinuousRecognitionAsync
public Future
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.
Returns: