Class SPXSpeechTranslationConfiguration

Declaration

@class SPXSpeechTranslationConfiguration : SPXSpeechConfiguration;

Description

Defines configurations for translation with speech input.

Methods

initWithSubscription:region:

Initializes speech translation configuration with the specified subscription key and service region.

- (instancetype _Nullable)initWithSubscription:(NSString * _Nonnull)subscriptionKey
    region:(NSString * _Nonnull)region

Parameters

  • subscriptionKey - the key of subscription to be used.
  • region - the region name (see the region page).

Returns

an instance of speech translation configuration.

initWithSubscription:region:error:

Initializes speech translation configuration with the specified subscription key and service region.

Added in version 1.6.0.

- (instancetype _Nullable)initWithSubscription:(NSString * _Nonnull)subscriptionKey
    region:(NSString * _Nonnull)region error:(NSError * _Nullable * _Nullable)outError

Parameters

  • subscriptionKey - the key of subscription to be used.
  • region - the region name (see the region page).
  • outError - error information.

Returns

an instance of speech translation configuration.

initWithAuthorizationToken:region:

Initializes speech translation configuration with the specified subscription key and service region.

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 setAuthorizationToken with a new valid token on the created recognizer. Otherwise, the recognizer instance will encounter errors during recognition. For long-living recognizers, the authorization token needs to be updated on the recognizer.

- (instancetype _Nullable)initWithAuthorizationToken:(NSString * _Nonnull)authToken
    region:(NSString * _Nonnull)region

Parameters

  • authToken - the authorization token.
  • region - the region name (see the region page).

Returns

an instance of speech translation configuration.

initWithAuthorizationToken:region:error:

Initializes speech translation configuration with the specified subscription key and service region.

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 setAuthorizationToken with a new valid token on the created recognizer. Otherwise, the recognizer instance will encounter errors during recognition. For long-living recognizers, the authorization token needs to be updated on the recognizer.

Added in version 1.6.0.

- (instancetype _Nullable)initWithAuthorizationToken:(NSString * _Nonnull)authToken
    region:(NSString * _Nonnull)region error:(NSError * _Nullable * _Nullable)outError

Parameters

  • authToken - the authorization token.
  • region - the region name (see the region page).
  • outError - error information.

Returns

an instance of speech translation configuration.

initWithEndpoint:subscription:

Initializes speech translation configuration 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 the URI as query parameter "language=de-DE", and is also set to "en-US" via property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, 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, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

- (instancetype _Nullable)initWithEndpoint:(NSString * _Nonnull)endpointUri
    subscription:(NSString * _Nonnull)subscriptionKey

Parameters

  • endpointUri - The service endpoint to connect to.
  • subscriptionKey - the subscription key.

Returns

an instance of speech translation configuration.

initWithEndpoint:subscription:error:

Initializes speech translation configuration 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 the URI as query parameter "language=de-DE", and is also set to "en-US" via property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, 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, use initWithEndpoint, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Added in version 1.6.0.

- (instancetype _Nullable)initWithEndpoint:(NSString * _Nonnull)endpointUri
    subscription:(NSString * _Nonnull)subscriptionKey
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • endpointUri - The service endpoint to connect to.
  • subscriptionKey - the subscription key.
  • outError - error information.

Returns

an instance of speech translation configuration.

initWithEndpoint:

Initializes speech translation configuration 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 the URI as query parameter "language=de-DE", and is also set to "en-US" via property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, 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 initWithEndpoint:subscription: to pass the subscription key as parameter. To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Note: Added in version 1.5.0.

- (instancetype _Nullable)initWithEndpoint:(NSString * _Nonnull)endpointUri

Parameters

  • endpointUri - The service endpoint to connect to.

Returns

an instance of speech translation configuration.

initWithEndpoint:error:

Initializes speech translation configuration 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 the URI as query parameter "language=de-DE", and is also set to "en-US" via property speechRecognitionLanguage in SPXSpeechTranslationConfiguration, 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 initWithEndpoint:subscription: to pass the subscription key as parameter. To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Note: Added in version 1.6.0.

- (instancetype _Nullable)initWithEndpoint:(NSString * _Nonnull)endpointUri
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • endpointUri - The service endpoint to connect to.
  • outError - error information.

Returns

an instance of speech translation configuration.

initWithHost:subscription:

Initializes speech translation configuration 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 initWithEndpoint instead.

Note: Query parameters are not allowed in the host URI and must be set by other APIs.

Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Added in version 1.8.0.

- (instancetype _Nullable)initWithHost:(NSString * _Nonnull)hostUri
    subscription:(NSString * _Nonnull)subscriptionKey

Parameters

  • hostUri - The service host to connect to. Format is "protocol://host:port" where ":port" is optional.
  • subscriptionKey - The subscription key.

Returns

An instance of speech translation configuration.

initWithHost:subscription:error:

Initializes speech translation configuration 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 initWithEndpoint instead.

Note: Query parameters are not allowed in the host URI and must be set by other APIs.

Note: To use an authorization token, use initWithHost, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Added in version 1.8.0.

- (instancetype _Nullable)initWithHost:(NSString * _Nonnull)hostUri
    subscription:(NSString * _Nonnull)subscriptionKey
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • hostUri - The service host to connect to. Format is "protocol://host:port" where ":port" is optional.
  • subscriptionKey - The subscription key.
  • outError - Error information.

Returns

An instance of speech translation configuration.

initWithHost:

Initializes speech translation configuration 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 initWithEndpoint 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 initWithHost:subscription: to pass the subscription key as parameter. To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Added in version 1.8.0.

- (instancetype _Nullable)initWithHost:(NSString * _Nonnull)hostUri

Parameters

  • hostUri - The service host to connect to. Format is "protocol://host:port" where ":port" is optional.

Returns

An instance of speech translation configuration.

initWithHost:error:

Initializes speech translation configuration 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 initWithEndpoint 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 initWithHost:subscription: to pass the subscription key as parameter. To use an authorization token, use this method to create a SPXSpeechTranslationConfig instance, and then set the authorizationToken property on the created SPXSpeechTranslationConfiguration instance.

Added in version 1.8.0.

- (instancetype _Nullable)initWithHost:(NSString * _Nonnull)hostUri
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • hostUri - The service host to connect to. Format is "protocol://host:port" where ":port" is optional.
  • outError - Error information.

Returns

An instance of speech translation configuration.

addTargetLanguage:

Adds a target language for translation.

- (void)addTargetLanguage:(NSString * _Nonnull)lang

Parameters

  • lang - the language identifier in BCP-47 format.

removeTargetLanguage:

Removes a target language for translation.

Added in version 1.7.0.

- (void)removeTargetLanguage:(NSString * _Nonnull)lang

Parameters

  • lang - the language identifier in BCP-47 format.

setCustomModelCategoryId:

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

- (void)setCustomModelCategoryId:(NSString * _Nonnull)categoryId

Parameters

  • categoryId - the category id for custom model.

Properties

targetLanguages

@property (readonly, copy, nonatomic) NSArray * _Nonnull targetLanguages;

All target languages that have been configured for translation.

voiceName

@property (readwrite, copy, nonatomic) NSString * _Nullable voiceName;

Voice name of the synthesis output of translated language.