Class 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.
    • 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,
                                                           com.azure.core.credential.KeyCredential keyCredential)
        Creates an instance of SpeechTranslationConfig with a custom endpoint and key credential. The query parameters specified in the endpoint URI are not changed, even if they are set by any other API call. For example, if the recognition language is defined in the URI query parameter as "language=de-DE", and the property SpeechRecognitionLanguage is set to "en-US", the language set in the URI takes precedence, and "de-DE" remains the expected language. Since parameters included in the endpoint URI take priority, only parameters that are not specified in the endpoint URI can be set by other APIs. To use an authorization token with FromEndpoint, use FromEndpoint(java.net.URI), and then set the AuthorizationToken property on the new SpeechConfig instance.
        Parameters:
        endpoint - The service endpoint to connect to.
        keyCredential - The key credential used to authenticate the request.
        Returns:
        A speech translation config instance.
      • fromEndpoint

        public static SpeechTranslationConfig fromEndpoint​(URI endpoint,
                                                           com.azure.core.credential.TokenCredential credential)
        Creates a speech configuration instance using a specified endpoint and AAD token credential. Introduced in version 1.43.0. Note:This API is available for TranslationRecognizer. Note:The AAD token is automatically refreshed before expiration. Note:This method requires a valid token credential. The authorization token is automatically refreshed before it expires. Note:Query parameters specified in the endpoint URI remain unchanged, even if modified through other APIs. The availability and support of specific query parameters depend on the endpoint and scenario. For example, if the URI contains the query parameter "language=de-DE", but the property SpeechRecognitionLanguage is set to "en-US", the URI setting takes precedence, and "de-DE" will be used as the recognition language. This behavior applies only when the endpoint and scenario combination supports language as a query parameter. Parameters not defined in the URI can be modified via other APIs. Note:If the endpoint requires authentication using a subscription key, use fromEndpoint(URI, String) to pass the key as a parameter. To authenticate with an authorization token, use fromEndpoint(URI), then set the AuthorizationToken property on the newly created SpeechConfig instance.
        Parameters:
        endpoint - The service endpoint with a custom domain. For more details, see: https://learn.microsoft.com/azure/ai-services/speech-service/speech-services-private-link?tabs=portal#create-a-custom-domain-name
        credential - The AAD token credential used for authentication and token requests.
        Returns:
        A speech translation config instance.
      • 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.
      • 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
      • getImpl

        public SafeHandle getImpl()
        Returns the speech translation config implementation
        Overrides:
        getImpl in class SpeechConfig
        Returns:
        The implementation of the speech translation config.
      • getTokenCredential

        public com.azure.core.credential.TokenCredential getTokenCredential()
        Retrieves the TokenCredential used for authentication.
        Overrides:
        getTokenCredential in class SpeechConfig
        Returns:
        The TokenCredential instance.