共用方式為


SpeechTranslationConfig Class

Implements

java.lang.AutoCloseable

public final class SpeechTranslationConfig
extends SpeechConfig
implements java.lang.AutoCloseable

Speech translation configuration. Note: close() must be called in order to release underlying resources held by the object.

Method Summary

Modifier and Type Method and Description
void addTargetLanguage(String value)

Adds a (text) target language for translation.

void close()

Dispose of associated resources.

static SpeechTranslationConfig fromAuthorizationToken(String authorizationToken, String region)

Static instance of SpeechTranslationConfig returned by passing authorization token and service region.

static SpeechTranslationConfig fromEndpoint(URI endpoint)

Creates an instance of the speech translation config with specified endpoint.

static SpeechTranslationConfig fromEndpoint(URI endpoint, String subscriptionKey)

Creates an instance of the speech translation config with specified endpoint and subscription key.

static SpeechTranslationConfig fromHost(URI host)

Creates an instance of the speech translation config with specified host.

static SpeechTranslationConfig fromHost(URI host, String subscriptionKey)

Creates an instance of the speech translation config with specified host and subscription key.

static SpeechTranslationConfig fromSubscription(String subscriptionKey, String region)

Static instance of SpeechTranslationConfig returned by passing subscriptionKey and service region.

SafeHandle getImpl()

Returns the speech translation config implementation

java.util.ArrayList<java.lang.String> getTargetLanguages()

Gets all target languages that have been configured for translation.

java.lang.String getVoiceName()

Returns the selected voice name.

void removeTargetLanguage(String value)

Removes a (text) target language for translation.

void setCustomModelCategoryId(String categoryId)

Sets a Category Id that will be passed to service.

void setVoiceName(String value)

Sets voice of the translated language, enable voice synthesis output.

Methods inherited from SpeechConfig

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

addTargetLanguage

public void addTargetLanguage(String value)

Adds a (text) target language for translation.

Parameters:

value - the language identifier in BCP-47 format.

close

public void close()

Dispose of associated resources.

Overrides:

SpeechTranslationConfig.close()

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)

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.

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.

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.

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.

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

getImpl

public SafeHandle getImpl()

Returns the speech translation config implementation

Overrides:

SpeechTranslationConfig.getImpl()

Returns:

The implementation of the speech translation config.

getTargetLanguages

public ArrayList 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.

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.

setCustomModelCategoryId

public void setCustomModelCategoryId(String categoryId)

Sets a Category Id that will be passed to service. Category Id is used to find the custom model.

Parameters:

categoryId - the category Id.

setVoiceName

public void setVoiceName(String value)

Sets voice of the translated language, enable voice synthesis output.

Parameters:

value - the voice name of synthesis output

Applies to