Class SpeechTranslationConfig
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.SpeechConfig
-
- com.microsoft.cognitiveservices.speech.translation.SpeechTranslationConfig
-
- All Implemented Interfaces:
AutoCloseable
public final class SpeechTranslationConfig extends SpeechConfig implements AutoCloseable
Speech translation configuration. Note: close() must be called in order to release underlying resources held by the object.
-
-
Field Summary
-
Fields inherited from class com.microsoft.cognitiveservices.speech.SpeechConfig
speechConfigClass
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTargetLanguage(String value)Adds a (text) target language for translation.voidclose()Dispose of associated resources.static SpeechTranslationConfigfromAuthorizationToken(String authorizationToken, String region)Static instance of SpeechTranslationConfig returned by passing authorization token and service region.static SpeechTranslationConfigfromEndpoint(URI endpoint)Creates an instance of the speech translation config with specified endpoint.static SpeechTranslationConfigfromEndpoint(URI endpoint, String subscriptionKey)Creates an instance of the speech translation config with specified endpoint and subscription key.static SpeechTranslationConfigfromHost(URI host)Creates an instance of the speech translation config with specified host.static SpeechTranslationConfigfromHost(URI host, String subscriptionKey)Creates an instance of the speech translation config with specified host and subscription key.static SpeechTranslationConfigfromSubscription(String subscriptionKey, String region)Static instance of SpeechTranslationConfig returned by passing subscriptionKey and service region.SafeHandlegetImpl()Returns the speech translation config implementationArrayList<String>getTargetLanguages()Gets all target languages that have been configured for translation.StringgetVoiceName()Returns the selected voice name.voidremoveTargetLanguage(String value)Removes a (text) target language for translation.voidsetVoiceName(String value)Sets voice of the translated language, enable voice synthesis output.-
Methods inherited from class com.microsoft.cognitiveservices.speech.SpeechConfig
enableAudioLogging, enableDictation, getAuthorizationToken, getEndpointId, getOutputFormat, getProperty, getProperty, getSpeechRecognitionLanguage, getSpeechSynthesisLanguage, getSpeechSynthesisOutputFormat, getSpeechSynthesisVoiceName, requestWordLevelTimestamps, setAuthorizationToken, setEndpointId, setOutputFormat, setProfanity, setProperty, setProperty, setProxy, setServiceProperty, setSpeechRecognitionLanguage, setSpeechSynthesisLanguage, setSpeechSynthesisOutputFormat, setSpeechSynthesisVoiceName
-
-
-
-
Method Detail
-
fromSubscription
public static SpeechTranslationConfig fromSubscription(String subscriptionKey, String region)
Static instance of SpeechTranslationConfig returned by passing subscriptionKey and service region.- Parameters:
subscriptionKey- The subscription key.region- The region name (see the region page).- Returns:
- The speech config
-
fromAuthorizationToken
public static SpeechTranslationConfig fromAuthorizationToken(String authorizationToken, String region)
Static instance of SpeechTranslationConfig returned by passing authorization token and service region. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expipres, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, all the recognizers created by this SpeechTranslationConfig instance will encounter errors during recognition.- Parameters:
authorizationToken- The authorization token.region- The region name (see the region page).- Returns:
- The speech config
-
fromEndpoint
public static SpeechTranslationConfig fromEndpoint(URI endpoint, String subscriptionKey)
Creates an instance of the speech translation config with specified endpoint and subscription key. This method is intended only for users who use a non-standard service endpoint or parameters. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by setSpeechRecognitionLanguage("en-US"), the language setting in URI takes precedence, and the effective language is "de-DE". Only the parameters that are not specified in the endpoint URI can be set by other APIs. Note: To use an authorization token with fromEndpoint, please use fromEndpoint(java.net.URI), and then call setAuthorizationToken() on the created SpeechTranslationConfig instance.- Parameters:
endpoint- The service endpoint to connect to.subscriptionKey- The subscription key.- Returns:
- A SpeechTranslationConfig instance.
-
fromEndpoint
public static SpeechTranslationConfig fromEndpoint(URI endpoint)
Creates an instance of the speech translation config with specified endpoint. This method is intended only for users who use a non-standard service endpoint or parameters. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by setSpeechRecognitionLanguage("en-US"), the language setting in URI takes precedence, and the effective language is "de-DE". Only the parameters that are not specified in the endpoint URI can be set by other APIs. Note: if the endpoint requires a subscription key for authentication, please use fromEndpoint(java.net.URI, String) to pass the subscription key as parameter. To use an authorization token with fromEndpoint, please use this method to create a SpeechTranslationConfig instance, and then call setAuthorizationToken() on the created SpeechTranslationConfig instance. Note: Added in version 1.5.0.- Parameters:
endpoint- The service endpoint to connect to.- Returns:
- A SpeechTranslationConfig instance.
-
fromHost
public static SpeechTranslationConfig fromHost(URI host, String subscriptionKey)
Creates an instance of the speech translation config with specified host and subscription key. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: To use an authorization token with fromHost, use fromHost(java.net.URI), and then call setAuthorizationToken() on the created SpeechTranslationConfig instance. Note: Added in version 1.8.0.- Parameters:
host- The service host to connect to. Format is "protocol://host:port" where ":port" is optional.subscriptionKey- The subscription key.- Returns:
- A SpeechTranslationConfig instance.
-
fromHost
public static SpeechTranslationConfig fromHost(URI host)
Creates an instance of the speech translation config with specified host. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: If the host requires a subscription key for authentication, use fromHost(java.net.URI, String) to pass the subscription key as parameter. To use an authorization token with fromHost, use this method to create a SpeechTranslationConfig instance, and then call setAuthorizationToken() on the created SpeechTranslationConfig instance. Note: Added in version 1.8.0.- Parameters:
host- The service host to connect to. Format is "protocol://host:port" where ":port" is optional.- Returns:
- A SpeechTranslationConfig instance.
-
addTargetLanguage
public void addTargetLanguage(String value)
Adds a (text) target language for translation.- Parameters:
value- the language identifier in BCP-47 format.
-
removeTargetLanguage
public void removeTargetLanguage(String value)
Removes a (text) target language for translation. Added in version 1.7.0.- Parameters:
value- the language identifier in BCP-47 format.
-
getTargetLanguages
public ArrayList<String> getTargetLanguages()
Gets all target languages that have been configured for translation.- Returns:
- the list of target languages.
-
getVoiceName
public String getVoiceName()
Returns the selected voice name.- Returns:
- The voice name.
-
setVoiceName
public void setVoiceName(String value)
Sets voice of the translated language, enable voice synthesis output.- Parameters:
value- the voice name of synthesis output
-
close
public void close()
Dispose of associated resources.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classSpeechConfig
-
getImpl
public SafeHandle getImpl()
Returns the speech translation config implementation- Overrides:
getImplin classSpeechConfig- Returns:
- The implementation of the speech translation config.
-
-