Introduction

The IBM® Text to Speech service provides APIs that use IBM's speech-synthesis capabilities to synthesize text into natural-sounding speech in a variety of languages, dialects, and voices. The service supports at least one male or female voice, sometimes both, for each language. The audio is streamed back to the client with minimal delay.

For speech synthesis, the service supports a synchronous HTTP Representational State Transfer (REST) interface. It also supports a WebSocket interface that provides both plain text and SSML input, including the SSML <mark> element and word timings. SSML is an XML-based markup language that provides text annotation for speech-synthesis applications.

The service also offers a customization interface. You can use the interface to define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more words that, when combined, sound like the word. A phonetic translation is based on the SSML phoneme format for representing a word. You can specify a phonetic translation in standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM Symbolic Phonetic Representation (SPR).

This documentation describes Java SDK major version 8. For details about how to migrate your code from the previous version see the migration guide.

This documentation describes Node SDK major version 5. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes Python SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes Ruby SDK major version 1. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes .NET Standard SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes Go SDK major version 1. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes Swift SDK major version 3. For details about how to migrate your code from the previous version, see the migration guide.

This documentation describes Unity SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.

Beginning with version 4.0.0, the Node SDK returns a Promise for all methods when a callback is not specified.

The package location moved to ibm-watson. It remains available at watson-developer-cloud but is not updated there. Use ibm-watson to stay up to date.

The IBM Watson Unity SDK has the following requirements.

  • The SDK requires Unity version 2018.2 or later to support TLS 1.2.
    • Set the project settings for both the Scripting Runtime Version and the Api Compatibility Level to .NET 4.x Equivalent.
    • For more information, see TLS 1.0 support.
  • The SDK does not support the WebGL projects. Change your build settings to any platform except WebGL.

For information about how to install and configure the SDK and SDK Core, see https://github.com/watson-developer-cloud/unity-sdk.

The code examples on this tab use the client library that is provided for Java.

Maven

<dependency>
  <groupId>com.ibm.watson</groupId>
  <artifactId>ibm-watson</artifactId>
  <version>8.0.1</version>
</dependency>

Gradle

compile 'com.ibm.watson:ibm-watson:8.0.1'

GitHub

The code examples on this tab use the client library that is provided for Node.js.

Installation

npm install ibm-watson@^5.1.0

GitHub

The code examples on this tab use the client library that is provided for Python.

Installation

pip install --upgrade "ibm-watson>=4.0.2"

GitHub

The code examples on this tab use the client library that is provided for Ruby.

Installation

gem install ibm_watson

GitHub

The code examples on this tab use the client library that is provided for Go.

go get -u github.com/watson-developer-cloud/go-sdk@v1.0.0

GitHub

The code examples on this tab use the client library that is provided for Swift.

Cocoapods

pod 'IBMWatsonTextToSpeechV1', '~> 3.0.0'

Carthage

github "watson-developer-cloud/swift-sdk" ~> 3.0.0

Swift Package Manager

.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "3.0.0")

GitHub

The code examples on this tab use the client library that is provided for .NET Standard.

Package Manager

Install-Package IBM.Watson.TextToSpeech.v1 -Version 4.0.0

.NET CLI

dotnet add package IBM.Watson.TextToSpeech.v1 -version 4.0.0

PackageReference

<PackageReference Include="IBM.Watson.TextToSpeech.v1" Version="4.0.0" />

GitHub

The code examples on this tab use the client library that is provided for Unity.

Github

Authentication

IBM Cloud Identity and Access Management (IAM) is the primary method to authenticate to the API. However, with some older service instances you authenticate by providing a username and password for the service instance.

  • For service instances that use IAM authentication, you can pass either a bearer token in an authorization header or an API key. Tokens support authenticated requests without embedding service credentials in every call. API keys use basic authentication. For more information, see Authenticating with IAM tokens.

    If you pass in an API key, use apikey for the username and the value of the API key as the password. For example, if the API key is f5sAznhrKQyvBFFaZbtF60m5tzLbqWhyALQawBg5TjRI in the service credentials, include the credentials in your call like this:

      curl -u "apikey:f5sAznhrKQyvBFFaZbtF60m5tzLbqWhyALQawBg5TjRI"
    
  • In other instances, you authenticate by providing the username and password for the service instance. For more information, see Authenticating with Cloud Foundry service credentials.

The SDK provides initialization methods for each form of authentication.

  • For service instances that use IAM authentication, the SDK provides two initialization methods: one that accepts an API key and another that accepts an access token created from an API key.

    • Use the API key to have the SDK manage the lifecycle of the token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
    • Use the access token to manage the lifecycle yourself. You must periodically refresh the token. For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.For more information, see IAM authentication with the SDK.
  • For service instances that use username and password authentication, use the BasicAuthenticator initialization method and specify the username and password. For more information, see Authenticating with Cloud Foundry service credentials.

To find out which authentication to use, view the service credentials by clicking the service instance in the Resource list.

The "username" and "password" in the service credentials are different from your IBM Cloud account IBMid and password.

IAM authentication. Replace {apikey} and {url} with your service credentials.

curl -u "apikey:{apikey}" -X {request_method} "{url}/{method}"

Basic authentication. Replace {username}, {password}, and {url} with your service credentials.

curl -u "{username}:{password}" -X {request_method} "{url}/{method}"

SDK managing the IAM token. Replace {apikey} and {url}.

IamAuthenticator authenticator = new IamAuthenticator("{apikey}");
TextToSpeech textToSpeech = new TextToSpeech(authenticator);
textToSpeech.setServiceUrl("{url}");

Basic authentication. Replace {username}, {password}, and {url}. Use either of the two constructors.

BasicAuthenticator authenticator = new BasicAuthenticator("{username}", "{password}");
TextToSpeech textToSpeech = new TextToSpeech( authenticator);
textToSpeech.setServiceUrl("{url}");

SDK managing the IAM token. Replace {apikey} and {url}.

const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
const { IamAuthenticator } = require('ibm-watson/auth');

const textToSpeech = new TextToSpeechV1({
  authenticator: new IamAuthenticator({
    apikey: '{apikey}',
  }),
  url: '{url}',
});

Basic authentication. Replace {username}, {password}, and {url}.

const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
const { BasicAuthenticator } = require('ibm-watson/auth');

const textToSpeech = new TextToSpeechV1({
  authenticator: new BasicAuthenticator({
    username: '{username}',
    password: '{password}',
  }),
  url: '{url}',
});

SDK managing the IAM token. Replace {apikey} and {url}.

from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('{apikey}')
text_to_speech = TextToSpeechV1(
    authenticator=authenticator
)

text_to_speech.set_service_url('{url}')

Basic authentication. Replace {username}, {password}, and {url}.

from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import BasicAuthenticator

authenticator = BasicAuthenticator('{username}','{password}')

text_to_speech = TextToSpeechV1(
)

text_to_speech.set_service_url('{url}')

SDK managing the IAM token. Replace {apikey} and {url}.

require "ibm_watson/authenticators"
require "ibm_watson/text_to_speech_v1"
include IBMWatson

authenticator = Authenticators::IamAuthenticator.new(
  apikey: "{apikey}"
)
text_to_speech = TextToSpeechV1.new(
  authenticator: authenticator
)
text_to_speech.service_url = "{url}"

Basic authentication. Replace {username}, {password}, and {url}.

require "ibm_watson/text_to_speech_v1"
include IBMWatson

authenticator = Authenticators::BasicAuthenticator.new(
  username: "{username}",
  password: "{password}"
)
text_to_speech = TextToSpeechV1.new(
  authenticator: authenticator
)
text_to_speech.service_url = "{url}";

SDK managing the IAM token. Replace {apikey} and {url}.

import (
  "github.com/IBM/go-sdk-core/core"
  "github.com/watson-developer-cloud/go-sdk/texttospeechv1"
)

func main() {
  authenticator := &core.IamAuthenticator{
    ApiKey: "{apikey}",
  }

  options := &texttospeechv1.TextToSpeechV1Options{
    Authenticator: authenticator,
  }

  textToSpeech, textToSpeechErr := texttospeechv1.NewTextToSpeechV1(options)

  if textToSpeechErr != nil {
    panic(textToSpeechErr)
  }

  textToSpeech.SetServiceURL("{url}")
}

Basic authentication. Replace {username}, {password}, and {url}.

import (
  "github.com/IBM/go-sdk-core/core"
  "github.com/watson-developer-cloud/go-sdk/texttospeechv1"
)

func main() {
  authenticator := &core.BasicAuthenticator{
    Username: "{username}",
    Password: "{password}",
  }

  options := &texttospeechv1.TextToSpeechV1Options{
    Authenticator: authenticator,
  }

  texttospeech, texttospeechErr := texttospeechv1.NewTextToSpeechV1(options)

  if texttospeechErr != nil {
  panic(texttospeechErr)
  }

  texttospeech.SetServiceURL("{url}")
}

SDK managing the IAM token. Replace {apikey} and {url}.

let authenticator = WatsonIAMAuthenticator(apiKey: "{apikey}")
let textToSpeech = TextToSpeech(authenticator: authenticator)
textToSpeech.serviceURL = "{url}"

Basic authentication. Replace {username}, {password}, and {url}.

let authenticator = WatsonBasicAuthenticator(username: "{username}", password: "{password}")
let textToSpeech = TextToSpeech(authenticator: authenticator)
textToSpeech.serviceURL = "{url}"

SDK managing the IAM token. Replace {apikey} and {url}.

IamAuthenticator authenticator = new IamAuthenticator(
    apikey: "{apikey}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

Basic authentication. Replace {username}, {password}, and {url}.

BasicAuthenticator authenticator = new BasicAuthenticator(
    username: "{username}",
    password: "{password}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

SDK managing the IAM token. Replace {apikey} and {url}.

var authenticator = new IamAuthenticator(
    apikey: "{apikey}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

Basic authentication. Replace {username}, {password}, and {url}.

var authenticator = new BasicAuthenticator(
    username: "{username}",
    password: "{password}");

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

Service endpoint

The service endpoint is based on the location of the service instance. For example, when Text to Speech is hosted in Washington DC, the base URL is https://gateway-wdc.watsonplatform.net/text-to-speech/api. The URL might also be different when you use IBM Cloud Dedicated.

To find out which URL to use, view the service credentials by clicking the service instance in the Resource list.

Use that URL in your requests to Text to Speech.

Set the correct service URL by calling the setServiceUrl() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the set_url() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the url= method of the service instance.

Set the correct service URL by the URL parameter when you create the service instance or by calling the SetURL= method of the service instance.

Set the correct service URL by setting the serviceURL property of the service instance.

Set the correct service URL by calling the SetEndpoint() method of the service instance.

Set the correct service URL by setting the Url property of the service instance.

Service endpoints by location:

  • Dallas: https://stream.watsonplatform.net/text-to-speech/api
  • Washington DC: https://gateway-wdc.watsonplatform.net/text-to-speech/api
  • Frankfurt: https://stream-fra.watsonplatform.net/text-to-speech/api
  • Sydney: https://gateway-syd.watsonplatform.net/text-to-speech/api
  • Tokyo: https://gateway-tok.watsonplatform.net/text-to-speech/api
  • London: https://gateway-lon.watsonplatform.net/text-to-speech/api
  • Seoul: https://gateway-seo.watsonplatform.net/text-to-speech/api

All locations might not support Text to Speech. For details, see Service availability.

Dallas API endpoint example

curl -u "apikey:{apikey}" -X {request_method} "https://stream.watsonplatform.net/text-to-speech/api"

Your service instance might not use this URL

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

IamAuthenticator authenticator = new IamAuthenticator("{apikey}");
TextToSpeech textToSpeech = new TextToSpeech(authenticator);
textToSpeech.setServiceUrl("https://gateway-wdc.watsonplatform.net/text-to-speech/api");

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
const { IamAuthenticator } = require('ibm-watson/auth');

const textToSpeech = new TextToSpeechV1({
  authenticator: new IamAuthenticator({
    apikey: '{apikey}',
  }),
  url: 'https://gateway-wdc.watsonplatform.net/text-to-speech/api',
});

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('{apikey}')
text_to_speech = TextToSpeechV1(
    authenticator=authenticator
)

text_to_speech.set_service_url('https://gateway-wdc.watsonplatform.net/text-to-speech/api')

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

require "ibm_watson/authenticators"
require "ibm_watson/text_to_speech_v1"
include IBMWatson

authenticator = Authenticators::IamAuthenticator.new(
  apikey: "{apikey}"
)
text_to_speech = TextToSpeechV1.new(
  authenticator: authenticator
)
text_to_speech.service_url = "https://gateway-wdc.watsonplatform.net/text-to-speech/api"

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

textToSpeech, textToSpeechErr := texttospeechv1.NewTextToSpeechV1(options)

if textToSpeechErr != nil {
  panic(textToSpeechErr)
}

textToSpeech.SetServiceURL("https://gateway-wdc.watsonplatform.net/text-to-speech/api")

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

let authenticator = WatsonIAMAuthenticator(apiKey: "{apikey}")
let textToSpeech = TextToSpeech(authenticator: authenticator)
textToSpeech.serviceURL = "https://gateway-wdc.watsonplatform.net/text-to-speech/api"

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

IamAuthenticator authenticator = new IamAuthenticator(
    apikey: "{apikey}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("https://gateway-wdc.watsonplatform.net/text-to-speech/api");

Default URL

https://stream.watsonplatform.net/text-to-speech/api

Example for the Washington DC location

var authenticator = new IamAuthenticator(
    apikey: "{apikey}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("https://gateway-wdc.watsonplatform.net/text-to-speech/api");

Disabling SSL verification

All Watson services use Secure Sockets Layer (SSL) (or Transport Layer Security (TLS)) for secure connections between the client and server. The connection is verified against the local certificate store to ensure authentication, integrity, and confidentiality.

If you use a self-signed certificate, you need to disable SSL verification to make a successful connection.

Enabling SSL verification is highly recommended. Disabling SSL jeopardizes the security of the connection and data. Disable SSL only if absolutely necessary, and take steps to enable SSL as soon as possible.

To disable SSL verification for a curl request, use the --insecure (-k) option with the request.

To disable SSL verification, create an HttpConfigOptions object and set the disableSslVerification property to true. Then pass the object to the service instance by using the configureClient method.

To disable SSL verification, set the disableSslVerification parameter to true when you create the service instance.

To disable SSL verification, specify true on the set_disable_ssl_verification method for the service instance.

To disable SSL verification, specify true on the configure_http_client method for the service instance.

To disable SSL verification, call the DisableSSLVerification method on the service instance.

To disable SSL verification, call the disableSSLVerification() method on the service instance. You cannot disable SSL verification on Linux.

To disable SSL verification, set the DisableSslVerification method to true on the service instance.

To disable SSL verification, set the DisableSslVerification method to true on the service instance.

Example that disables SSL verification

IAM authentication. Replace {apikey} and {url} with your service credentials.

curl -k -u "apikey:{apikey}" -X {request_method} "{url}/{method}"

Example that disables SSL verification

IamAuthenticator authenticator = new IamAuthenticator("{apikey}");
TextToSpeech textToSpeech = new TextToSpeech(authenticator);
textToSpeech.setServiceUrl("{url}");

HttpConfigOptions configOptions = new HttpConfigOptions.Builder()
  .disableSslVerification(true)
  .build();
textToSpeech.configureClient(configOptions);

Example that disables SSL verification

const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
const { IamAuthenticator } = require('ibm-watson/auth');

const textToSpeech = new TextToSpeechV1({
  authenticator: new IamAuthenticator({
    apikey: '{apikey}',
  }),
  url: '{url}',
  disableSslVerification: true,
});

Example that disables SSL verification

from ibm_watson import TextToSpeechV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('{apikey}')
text_to_speech = TextToSpeechV1(
    authenticator=authenticator
)

text_to_speech.set_service_url('{url}')

text_to_speech.set_disable_ssl_verification(True)

Example that disables SSL verification

require "ibm_watson/authenticators"
require "ibm_watson/text_to_speech_v1"
include IBMWatson

authenticator = Authenticators::IamAuthenticator.new(
  apikey: "{apikey}"
)
text_to_speech = TextToSpeechV1.new(
  authenticator: authenticator
)
text_to_speech.service_url = "{url}"

text_to_speech.configure_http_client(disable_ssl: true)

Example that disables SSL verification

textToSpeech, textToSpeechErr := texttospeechv1.NewTextToSpeechV1(options)

if textToSpeechErr != nil {
  panic(textToSpeechErr)
}

textToSpeech.SetServiceURL("{url}")

textToSpeech.DisableSSLVerification()

Example that disables SSL verification

let authenticator = WatsonIAMAuthenticator(apiKey: "{apikey}")
let textToSpeech = TextToSpeech(authenticator: authenticator)
textToSpeech.serviceURL = "{url}"

textToSpeech.disableSSLVerification()

Example that disables SSL verification

IamAuthenticator authenticator = new IamAuthenticator(
    apikey: "{apikey}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.DisableSslVerification(true);

Example that disables SSL verification

var authenticator = new IamAuthenticator(
    apikey: "{apikey}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.DisableSslVerification = true;

Error handling

The Text to Speech service uses standard HTTP response codes to indicate whether a method completed successfully. HTTP response codes in the 2xx range indicate success. A response in the 4xx range is some sort of failure, and a response in the 5xx range usually indicates an internal system error that cannot be resolved by the user. Response codes are listed with the method.

ErrorResponse

Name Description
error
string
Description of the problem.
code
integer
HTTP response code.
code_description
string
Response message.
warnings
string
Warnings associated with the error.

The Java SDK generates an exception for any unsuccessful method invocation. All methods that accept an argument can also throw an IllegalArgumentException.

Exception Description
IllegalArgumentException An illegal argument was passed to the method.

When the Java SDK receives an error response from the Text to Speech service, it generates an exception from the com.ibm.watson.developer_cloud.service.exception package. All service exceptions contain the following fields.

Field Description
statusCode The HTTP response code that is returned.
message A message that describes the error.

When the Node SDK receives an error response from the Text to Speech service, it creates an Error object with information that describes the error that occurred. This error object is passed as the first parameter to the callback function for the method. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Python SDK generates an exception for any unsuccessful method invocation. When the Python SDK receives an error response from the Text to Speech service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

When the Ruby SDK receives an error response from the Text to Speech service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

The Go SDK generates an error for any unsuccessful service instantiation and method invocation. You can check for the error immediately. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Swift SDK returns a WatsonError in the completionHandler any unsuccessful method invocation. This error type is an enum that conforms to LocalizedError and contains an errorDescription property that returns an error message. Some of the WatsonError cases contain associated values that reveal more information about the error.

Field Description
errorDescription A message that describes the error.

When the .NET Standard SDK receives an error response from the Text to Speech service, it generates a ServiceResponseException that contains the following fields.

Field Description
Message A message that describes the error.
CodeDescription The HTTP response code that is returned.

When the Unity SDK receives an error response from the Text to Speech service, it generates an IBMError that contains the following fields.

Field Description
Url The URL that generated the error.
StatusCode The HTTP response code returned.
ErrorMessage A message that describes the error.
Response The contents of the response from the server.
ResponseHeaders A dictionary of headers returned by the request.

Example error handling

try {
  // Invoke a Text to Speech method
} catch (NotFoundException e) {
  // Handle Not Found (404) exception
} catch (RequestTooLargeException e) {
  // Handle Request Too Large (413) exception
} catch (ServiceResponseException e) {
  // Base class for all exceptions caused by error responses from the service
  System.out.println("Service returned status code "
    + e.getStatusCode() + ": " + e.getMessage());
}

Example error handling

textToSpeech.method(params)
  .catch(err => {
    console.log('error:', err);
  });

Example error handling

from ibm_watson import ApiException
try:
    # Invoke a Text to Speech method
except ApiException as ex:
    print "Method failed with status code " + str(ex.code) + ": " + ex.message

Example error handling

require "ibm_watson"
begin
  # Invoke a Text to Speech method
rescue IBMWatson::ApiException => ex
  print "Method failed with status code #{ex.code}: #{ex.error}"
end

Example error handling

import "github.com/watson-developer-cloud/go-sdk/texttospeechv1"

// Instantiate a service
textToSpeech, textToSpeechErr := texttospeechv1.NewTextToSpeechV1(options)

// Check for errors
if textToSpeechErr != nil {
  panic(textToSpeechErr)
}

// Call a method
result, response, responseErr := textToSpeech.methodName(&methodOptions)

// Check for errors
if responseErr != nil {
  panic(responseErr)
}

Example error handling

textToSpeech.method() {
  response, error in

  if let error = error {
    switch error {
    case let .http(statusCode, message, metadata):
      switch statusCode {
      case .some(404):
        // Handle Not Found (404) exception
        print("Not found")
      case .some(413):
        // Handle Request Too Large (413) exception
        print("Payload too large")
      default:
        if let statusCode = statusCode {
          print("Error - code: \(statusCode), \(message ?? "")")
        }
      }
    default:
      print(error.localizedDescription)
    }
    return
  }

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }

  print(result)
}

Example error handling

try
{
    // Invoke a Watson textToSpeech method
}
catch(ServiceResponseException e)
{
    Console.WriteLine("Error: " + e.Message);
}
catch (Exception e)
{
    Console.WriteLine("Error: " + e.Message);
}

Example error handling

// Invoke a method
textToSpeech.MethodName(Callback, Parameters);

// Check for errors
private void Callback(DetailedResponse<ExampleResponse> response, IBMError error)
{
    if (error == null)
    {
        Log.Debug("ExampleCallback", "Response received: {0}", response.Response);
    }
    else
    {
        Log.Debug("ExampleCallback", "Error received: {0}, {1}, {3}", error.StatusCode, error.ErrorMessage, error.Response);
    }
}

Data handling

Additional headers

Some Watson services accept special parameters in headers that are passed with the request.

You can pass request header parameters in all requests or in a single request to the service.

To pass a request header, use the --header (-H) option with a curl request.

To pass header parameters with every request, use the setDefaultHeaders method of the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, use the addHeader method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the headers parameter when you create the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, use the headers method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the set_default_headers method of the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, include headers as a dict in the request.

To pass header parameters with every request, specify the add_default_headers method of the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, specify the headers method as a chainable method in the request.

To pass header parameters with every request, specify the SetDefaultHeaders method of the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, specify the Headers as a map in the request.

To pass header parameters with every request, add them to the defaultHeaders property of the service object. See Data collection for an example use of this method.

To pass header parameters in a single request, pass the headers parameter to the request method.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

Example header parameter in a request

curl -u "apikey:{apikey}" -X {request_method} --header "Request-Header: {header_value}" "{url}/{method}"

Example header parameter in a request

ReturnType returnValue = textToSpeech.methodName(parameters)
  .addHeader("Custom-Header", "{header_value}")
  .execute();

Example header parameter in a request

const parameters = {
  {parameters}
};

textToSpeech.methodName(
  parameters,
  headers: {
    'Custom-Header': '{header_value}'
  })
   .then(result => {
    console.log(response);
  })
  .catch(err => {
    console.log('error:', err);
  });

Example header parameter in a request

response = text_to_speech.methodName(
    parameters,
    headers = {
        'Custom-Header': '{header_value}'
    })

Example header parameter in a request

response = text_to_speech.headers(
  "Custom-Header" => "{header_value}"
).methodName(parameters)

Example header parameter in a request

result, response, _ := texttospeechv1.methodName(
  &methodOptions{
    Headers: map[string]string{
      "Accept": "application/json",
    },
  },
)

Example header parameter in a request

let customHeader: [String: String] = ["Custom-Header": "{header_value}"]
textToSpeech.methodName(parameters, headers: customHeader) {
  response, error in
}

Example header parameter in a request

IamAuthenticator authenticator = new IamAuthenticator(
    apikey: "{apikey}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.WithHeader("Custom-Header", "header_value");

Example header parameter in a request

var authenticator = new IamAuthenticator(
    apikey: "{apikey}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.WithHeader("Custom-Header", "header_value");

Response details

The Text to Speech service might return information to the application in response headers.

To access all response headers that the service returns, include the --include (-i) option with a curl request. To see detailed response data for the request, including request headers, response headers, and additional debugging information, include the --verbose (-v) option with the request.

Example request to access response headers

curl -u "apikey:{apikey}" -X {request_method} --include "{url}/{method}"

To access information in the response headers, use one of the request methods that returns details with the response: executeWithDetails(), enqueueWithDetails(), or rxWithDetails(). These methods return a Response<T> object, where T is the expected response model. Use the getResult() method to access the response object for the method, and use the getHeaders() method to access information in response headers.

Example request to access response headers

Response<ReturnType> response = textToSpeech.methodName(parameters)
  .executeWithDetails();
// Access response from methodName
ReturnType returnValue = response.getResult();
// Access information in response headers
Headers responseHeaders = response.getHeaders();

All response data is available in the Response<T> object that is returned by each method. To access information in the response object, use the following properties.

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

textToSpeech.methodName(parameters)
  .then(response => {
    console.log(response.headers);
  })
  .catch(err => {
    console.log('error:', err);
  });

The return value from all service methods is a DetailedResponse object. To access information in the result object or response headers, use the following methods.

DetailedResponse

Method Description
get_result() Returns the response for the service-specific method.
get_headers() Returns the response header information.
get_status_code() Returns the HTTP status code.

Example request to access response headers

text_to_speech.set_detailed_response(True)
response = text_to_speech.methodName(parameters)
# Access response from methodName
print(json.dumps(response.get_result(), indent=2))
# Access information in response headers
print(response.get_headers())
# Access HTTP response status
print(response.get_status_code())

The return value from all service methods is a DetailedResponse object. To access information in the response object, use the following properties.

DetailedResponse

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

response = text_to_speech.methodName(parameters)
# Access response from methodName
print response.result
# Access information in response headers
print response.headers
# Access HTTP response status
print response.status

The return value from all service methods is a DetailedResponse object. To access information in the response object or response headers, use the following methods.

DetailedResponse

Method Description
GetResult() Returns the response for the service-specific method.
GetHeaders() Returns the response header information.
GetStatusCode() Returns the HTTP status code.

Example request to access response headers

import "github.com/IBM/go-sdk-core/core"
result, response, _ := texttospeechv1.methodName(&methodOptions{})

// Access result
core.PrettyPrint(response.GetResult(), "Result ")

// Access response headers
core.PrettyPrint(response.GetHeaders(), "Headers ")

// Access status code
core.PrettyPrint(response.GetStatusCode(), "Status Code ")

All response data is available in the WatsonResponse<T> object that is returned in each method's completionHandler.

Example request to access response headers

textToSpeech.methodName(parameters) {
  response, error in

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }
  print(result) // The data returned by the service
  print(response?.statusCode)
  print(response?.headers)
}

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

var results = textToSpeech.MethodName(parameters);

var result = results.Result;            //  The result object
var responseHeaders = results.Headers;  //  The response headers
var responseJson = results.Response;    //  The raw response JSON
var statusCode = results.StatusCode;    //  The response status code

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

private void Example()
{
    textToSpeech.MethodName(Callback, Parameters);
}

private void Callback(DetailedResponse<ResponseType> response, IBMError error)
{
    var result = response.Result;                 //  The result object
    var responseHeaders = response.Headers;       //  The response headers
    var responseJson = reresponsesults.Response;  //  The raw response JSON
    var statusCode = response.StatusCode;         //  The response status code
}

Data labels

You can remove customer data if you associate the customer and the data when you send the information to a service. First, you label the data with a customer ID, and then you can delete the data by the ID.

  • Use the X-Watson-Metadata header to associate a customer ID with the data. By adding a customer ID to a request, you indicate that it contains data that belongs to that customer.

    Specify a random or generic string for the customer ID. Do not include personal data, such as an email address. Pass the string customer_id={id} as the argument of the header.

  • Use the Delete labeled data method to remove data that is associated with a customer ID.

Labeling data is used only by methods that accept customer data. For more information about Text to Speech and labeling data, see Information security.

For more information about how to pass headers, see Additional headers.

Data collection

By default, all Watson services log requests and their results. Logging is done only to improve the services for future users. The logged data is not shared or made public.

To prevent IBM usage of your data for an API request, set the X-Watson-Learning-Opt-Out header parameter to true.

You must set the header on each request that you do not want IBM to access for general service improvements.

You can set the header by using the setDefaultHeaders method of the service object.

You can set the header by using the headers parameter when you create the service object.

You can set the header by using the set_default_headers method of the service object.

You can set the header by using the add_default_headers method of the service object.

You can set the header by using the SetDefaultHeaders method of the service object.

You can set the header by adding it to the defaultHeaders property of the service object.

You can set the header by using the WithHeader() method of the service object.

Example request

curl -u "apikey:{apikey}" -H "X-Watson-Learning-Opt-Out: true" "{url}/{method}"

Example request

Map<String, String> headers = new HashMap<String, String>();
headers.put("X-Watson-Learning-Opt-Out", "true");

textToSpeech.setDefaultHeaders(headers);

Example request

const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
const { IamAuthenticator } = require('ibm-watson/auth');

const textToSpeech = new TextToSpeechV1({
  authenticator: new IamAuthenticator({
    apikey: '{apikey}',
  }),
  url: '{url}',
  headers: {
    'X-Watson-Learning-Opt-Out': 'true'
  }
});

Example request

text_to_speech.set_default_headers({'x-watson-learning-opt-out': "true"})

Example request

text_to_speech.add_default_headers(headers: {"x-watson-learning-opt-out" => "true"})

Example request

import "net/http"

headers := http.Header{}
headers.Add("x-watson-learning-opt-out", "true")
textToSpeech.SetDefaultHeaders(headers)

Example request

textToSpeech.defaultHeaders["X-Watson-Learning-Opt-Out"] = "true"

Example request

IamAuthenticator authenticator = new IamAuthenticator(
    apikey: "{apikey}"
    );

TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.WithHeader("X-Watson-Learning-Opt-Out", "true");

Example request

var authenticator = new IamAuthenticator(
    apikey: "{apikey}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("{url}");

textToSpeech.WithHeader("X-Watson-Learning-Opt-Out", "true");

Synchronous and asynchronous requests

The Java SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the ServiceCall interface.

  • To call a method synchronously, use the execute method of the ServiceCall interface. You can call the execute method directly from an instance of the service.
  • To call a method asynchronously, use the enqueue method of the ServiceCall interface to receive a callback when the response arrives. The ServiceCallback interface of the method's argument provides onResponse and onFailure methods that you override to handle the callback.

The Ruby SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the Concurrent::Async module. When you use the synchronous or asynchronous methods, an IVar object is returned. You access the DetailedResponse object by calling ivar_object.value.

For more information about the Ivar object, see the IVar class docs.

  • To call a method synchronously, either call the method directly or use the .await chainable method of the Concurrent::Async module.

    Calling a method directly (without .await) returns a DetailedResponse object.

  • To call a method asynchronously, use the .async chainable method of the Concurrent::Async module.

You can call the .await and .async methods directly from an instance of the service.

Example synchronous request

ReturnType returnValue = textToSpeech.method(parameters).execute();

Example asynchronous request

textToSpeech.method(parameters).enqueue(new ServiceCallback<ReturnType>() {
  @Override public void onResponse(ReturnType response) {
    . . .
  }
  @Override public void onFailure(Exception e) {
    . . .
  }
});

Example synchronous request

response = text_to_speech.method_name(parameters)

or

response = text_to_speech.await.method_name(parameters)

Example asynchronous request

response = text_to_speech.async.method_name(parameters)

WebSockets

Synthesize audio (WebSockets)

Synthesizes text to spoken audio over a WebSocket connection. The synthesize method establishes a connection with the service. You then send the text to be synthesized to the service as a JSON text message over the connection. The service returns the audio as a stream of binary data.

The endpoint for the WebSocket API is

wss://{host_name}/text-to-speech/api/v1/synthesize

where {host_name} is the location in which your application is hosted:

  • stream.watsonplatform.net for Dallas
  • gateway-wdc.watsonplatform.net for Washington DC
  • stream-fra.watsonplatform.net for Frankfurt
  • gateway-syd.watsonplatform.net for Sydney
  • gateway-tok.watsonplatform.net for Tokyo
  • gateway-lon.watsonplatform.net for London
  • gateway-seo.watsonplatform.net for Seoul

The examples in the documentation abbreviate wss://{host_name}/text-to-speech/api to {ws_url}. So all WebSocket examples call the method as {ws_url}/v1/synthesize.

You can provide a maximum of 5 KB of either plain text or text that is annotated with SSML. You can use the SSML <mark> element to request the location of the marker in the audio stream. You can also request word timing information in the form of start and end times for all strings of the input text. The service returns mark and word timing results as text messages over the connection.

The WebSocket interface cannot be called from curl. Use a client-side scripting language to call the interface. The example request uses JavaScript to invoke the WebSocket synthesize method.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the accept parameter to specify the requested format of the response audio. Specify */* with the parameter to use the default, Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • */* - Specifies the default audio format: audio/ogg;codecs=opus.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

URI /v1/synthesize

Request

The client establishes a connection with the service by using the WebSocket constructor to create an instance of a WebSocket connection object. The constructor sets the following basic parameters for the connection and the synthesis.

Parameters of synthesize method

  • If you use IAM authentication, pass a valid IAM access token to authenticate with the service. You pass an IAM access token instead of passing an API key with the call. You must use the access token before it expires. For information about obtaining an access token, see Authenticating with IAM tokens.

  • If you use Cloud Foundry service credentials, pass a valid Watson authentication token to authenticate with the service. You pass a token instead of passing service credentials with the call. Watson tokens are based on Cloud Foundry service credentials, which use a username and password for HTTP basic authentication. For information about obtaining a Watson token, see Watson tokens.

  • The voice to use for the synthesis. See Languages and voices.

    Allowable values: [de-DE_BirgitVoice, de-DE_BirgitV3Voice, de-DE_DieterVoice, de-DE_DieterV3Voice, en-GB_KateVoice, en-GB_KateV3Voice, en-US_AllisonVoice, en-US_AllisonV3Voice, en-US_LisaVoice, en-US_LisaV3Voice, en-US_MichaelVoice, en-US_MichaelV3Voice, es-ES_LauraVoice, es-ES_LauraV3Voice, es-ES_EnriqueVoice, es-ES_EnriqueV3Voice, es-LA_SofiaVoice, es-LA_SofiaV3Voice, es-US_SofiaVoice, es-US_SofiaV3Voice, fr-FR_ReneeVoice, fr-FR_ReneeV3Voice, it-IT_FrancescaVoice, it-IT_FrancescaV3Voice, ja-JP_EmiVoice, ja-JP_EmiV3Voice, pt-BR_IsabelaVoice, pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model that is to be used for the synthesis. A custom voice model is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

  • Indicates whether IBM can use data that is sent over the connection to improve the service for future users. Specify true to prevent IBM from accessing the logged data. See Data collection.

    Default: false

  • Associates a customer ID with all data that is passed over the connection. The parameter accepts the argument customer_id={id}, where {id} is a random or generic string that is to be associated with the data. URL-encode the argument to the parameter, for example customer_id%3dmy_ID. By default, no customer ID is associated with the data. See Data labels.

The client initiates the synthesis by sending a JSON-formatted text message to the service over the connection.

Parameters of WebSocket text messages

  • The text that us to be synthesized. Provide plain text or text that is annotated with SSML. SSML input can include the SSML <mark> element. Pass a maximum of 5 KB of text.

  • The requested format (MIME type) of the audio. Specify */* to use the default, Ogg format with the Opus codec (audio/ogg;codecs=opus). For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, audio/webm;codecs=vorbis, */*]

  • An array that specifies whether the service is to return word timing information for all strings of the input text. Specify words as the element of the array to request word timing information. The service returns the start and end time of each word of the input. Specify an empty array or omit the parameter to receive no word timing information. Not supported for Japanese input text.

Response

Returns the binary audio stream for the input text as an array of bytes in the specified audio format (MIME type).

If the input text includes one or more SSML <mark> elements, the service returns one or more text messages that include one or more Marks objects.

Marks

  • The location of one or more marks in the audio stream. Each inner list has two elements: the name of the mark and the time in seconds at which the word occurs in the audio. For example, [["here", 0.4019387755102041]].

If the request includes the timings parameter to request word timing information, the service returns one or more text messages that include one or more Timings objects.

Timings

  • Word timing information for one or more strings in the audio stream. Each inner list consists of three elements: a word from the input text followed by the start and end time in seconds at which the word occurs in the audio. For example, ["Hello", [0.0690258394023930, 0.1655782733012873]].

Response handling

Response handling for the WebSocket interface is different from HTTP response handling. The WebSocket constructor returns an instance of a WebSocket connection object. You assign application-specific calls to the following methods of the object to handle events that are associated with the connection. Each event handler must accept a single argument for an event from the connection. The event that it accepts causes it to execute.

Methods

  • The status of the connection's opening.

  • Response messages from the service, including the results of the synthesis as a binary stream.

  • Errors for the connection or request.
  • The status of the connection's closing.

The connection can produce the following return codes.

Return code

  • The connection closed normally.

  • The connection closed due to a protocol error.

  • The connection closed abnormally.

  • The connection closed because the frame size exceeded the 4 MB limit.

  • The service is terminating the connection because it encountered an unexpected condition that prevents it from fulfilling the request, such as an invalid argument. The return code can also indicate that the input text was too large. The text cannot exceed 5 KB in size.

If any errors or warnings are associated with the connection, the service sends a JSON response as a text message with one of the following fields.

Connection response

  • An error message that describes the problem. The message is followed by a second message that includes the boolean value true to indicate that the connection is closed, the return code for the error, and a brief message. The connection is closed.

  • Warning messages about invalid or unknown parameters included with the request. The warning includes a descriptive message and a list of invalid argument strings. For example, "Unknown arguments: {invalid_arg_1}, {invalid_arg_2}." The connection remains open.

Example request

var IAM_access_token = '{access_token}';
var wsURI = '{ws_url}/v1/synthesize'
  + '?access_token=' + IAM_access_token
  + '&voice=en-US_AllisonVoice';

function onOpen(evt) {
  var message = {
    text: 'Hello world',
    accept: 'audio/ogg;codecs=opus'
  };
  // The service currently accepts a single message per WebSocket connection.
  websocket.send(JSON.stringify(message));
}

var audioParts = [];
var finalAudio;

function onMessage(evt) {
  if (typeof evt.data === 'string') {
    console.log('Received string message: ', evt.data)
  } else {
    console.log('Received ' + evt.data.size + ' binary bytes', evt.data.type);
    audioParts.push(evt.data);
  }
}

function onClose(evt) {
  console.log('WebSocket closed', evt.code, evt.reason);
  finalAudio = new Blob(audioParts, {type: format});
  console.log('final audio: ', finalAudio);
}

function onError(evt) {
  console.log('WebSocket error', evt);
}

var websocket = new WebSocket(wsURI);
websocket.onopen = onOpen;
websocket.onclose = onClose;
websocket.onmessage = onMessage;
websocket.onerror = onError;

Methods

List voices

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

Lists all voices available for use with the service. The information includes the name, language, gender, and other details about the voice. To see information about a specific voice, use the Get a voice method.

See also: Listing all available voices.

GET /v1/voices
(textToSpeech *TextToSpeechV1) ListVoices(listVoicesOptions *ListVoicesOptions) (result *Voices, response *core.DetailedResponse, err error)
ServiceCall<Voices> listVoices()
listVoices(params, [callback()])
list_voices(self, **kwargs)
list_voices
func listVoices(
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Voices>?, WatsonError?) -> Void)
ListVoices()
ListVoices(Callback<Voices> callback)
Request

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

No Request Parameters

This method does not accept any request parameters.

Response

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Information about all available voice models.

Status Code

  • OK. The request succeeded.

  • Not Modified. The requested resource has not been modified since the time specified by the If-Modified-Since header, as documented in the HTTP specification.

  • Not Acceptable. The request specified an Accept header with an incompatible content type.

  • Unsupported Media Type. The request specified an unacceptable media type.

Example responses

Get a voice

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

Gets information about the specified voice. The information includes the name, language, gender, and other details about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the language of the specified voice. To list information about all available voices, use the List voices method.

See also: Listing a specific voice.

GET /v1/voices/{voice}
(textToSpeech *TextToSpeechV1) GetVoice(getVoiceOptions *GetVoiceOptions) (result *Voice, response *core.DetailedResponse, err error)
ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions)
getVoice(params, [callback()])
get_voice(self, voice, customization_id=None, **kwargs)
get_voice(voice:, customization_id: nil)
func getVoice(
    voice: String,
    customizationID: String? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Voice>?, WatsonError?) -> Void)
GetVoice(string voice, string customizationId = null)
GetVoice(Callback<Voice> callback, string voice, string customizationId = null)
Request

Instantiate the GetVoiceOptions struct and set the fields to provide parameter values for the GetVoice method.

Use the GetVoiceOptions.Builder to create a GetVoiceOptions object that contains the parameter values for the getVoice method.

Path Parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

Query Parameters

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

The GetVoice options.

The getVoice options.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

parameters

  • The voice for which information is to be returned.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

  • The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see information about the specified voice with no customization.

Response

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Information about an available voice model.

Status Code

  • OK. The request succeeded.

  • Not Modified. The requested resource has not been modified since the time specified by the If-Modified-Since header, as documented in the HTTP specification.

  • Bad Request. A required input parameter is null or a specified input parameter or header value is invalid or not supported. Specific messages include

    • Invalid value for 'customization_id'
  • Unauthorized. The specified customization_id is invalid for the requesting credentials:

    • Invalid customization_id ({id}) for user
  • Not Acceptable. The request specified an Accept header with an incompatible content type.

  • Unsupported Media Type. The request specified an unacceptable media type.

Example responses

Synthesize audio (GET)

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 8 KB of input, which includes the input text and the URL and headers. The 8 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

GET /v1/synthesize
Request

Custom Headers

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

Query Parameters

  • The text to synthesize. Specify either plain text or a subset of SSML. SSML is an XML-based markup language that provides text annotation for speech-synthesis applications. Pass a maximum of 8 KB of input, which includes the input text and the URL and headers.

  • The requested format (MIME type) of the audio. You can use the accept parameter or the Accept header to specify the audio format. URL-encode the argument to the accept parameter; for example, audio/mulaw;rate=8000 becomes audio%2Fmulaw%3Brate%3D8000. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

Response

A binary file that contains the audio of the response.

Status Code

  • OK. The request succeeded.

  • Not Modified. The requested resource has not been modified since the time specified by the If-Modified-Since header, as documented in the HTTP specification.

  • Bad Request. A required input parameter is null or a specified input parameter or header value is invalid. If the request fails SSML validation, the description of the error explains the failure; for more information, see SSML validation.

  • Not Acceptable. The request specified an incompatible content type or failed to specify a required sampling rate.

  • Unsupported Media Type. The request specified an unacceptable media type.

  • Internal Server Error. The service experienced an internal error

  • Service Unavailable. The service is currently unavailable.

No Sample Response

This method does not specify any sample responses.

Synthesize audio

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the language for the input text on the specified voice. Use a voice that matches the language of the input text.

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an array of bytes.

See also: The HTTP interface.

Audio formats (accept types)

The service can return audio in the following formats (MIME types).

  • Where indicated, you can optionally specify the sampling rate (rate) of the audio. You must specify a sampling rate for the audio/l16 and audio/mulaw formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted.
  • For the audio/l16 format, you can optionally specify the endianness (endianness) of the audio: endianness=big-endian or endianness=little-endian.

Use the Accept header or the accept parameter to specify the requested format of the response audio. If you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec (audio/ogg;codecs=opus). The service always returns single-channel audio.

  • audio/basic - The service returns audio with a sampling rate of 8000 Hz.
  • audio/flac - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/l16 - You must specify the rate of the audio. You can optionally specify the endianness of the audio. The default endianness is little-endian.
  • audio/mp3 - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mpeg - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/mulaw - You must specify the rate of the audio.
  • audio/ogg - The service returns the audio in the vorbis codec. You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/ogg;codecs=opus - You can optionally specify the rate of the audio. Only the following values are valid sampling rates: 48000, 24000, 16000, 12000, or 8000. If you specify a value other than one of these, the service returns an error. The default sampling rate is 48,000 Hz.
  • audio/ogg;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/wav - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.
  • audio/webm - The service returns the audio in the opus codec. The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=opus - The service returns audio with a sampling rate of 48,000 Hz.
  • audio/webm;codecs=vorbis - You can optionally specify the rate of the audio. The default sampling rate is 22,050 Hz.

For more information about specifying an audio format, including additional details about some of the formats, see Audio formats.

Warning messages

If a request includes invalid query parameters, the service returns a Warnings response header that provides messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument strings. For example, a message such as "Unknown arguments:" or "Unknown url query arguments:" followed by a list of the form "{invalid_arg_1}, {invalid_arg_2}." The request succeeds despite the warnings.

POST /v1/synthesize
(textToSpeech *TextToSpeechV1) Synthesize(synthesizeOptions *SynthesizeOptions) (result io.ReadCloser, response *core.DetailedResponse, err error)
ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions)
synthesize(params, [callback()])
synthesize(self, text, accept=None, voice=None, customization_id=None, **kwargs)
synthesize(text:, accept: nil, voice: nil, customization_id: nil)
func synthesize(
    text: String,
    accept: String? = nil,
    voice: String? = nil,
    customizationID: String? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Data>?, WatsonError?) -> Void)
Synthesize(string text, string accept = null, string voice = null, string customizationId = null)
Synthesize(Callback<byte[]> callback, string text, string accept = null, string voice = null, string customizationId = null)
Request

Instantiate the SynthesizeOptions struct and set the fields to provide parameter values for the Synthesize method.

Use the SynthesizeOptions.Builder to create a SynthesizeOptions object that contains the parameter values for the synthesize method.

Custom Headers

  • The type of the input.

    Allowable values: [application/json]

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

Query Parameters

  • The requested format (MIME type) of the audio. You can use the accept parameter or the Accept header to specify the audio format. URL-encode the argument to the accept parameter; for example, audio/mulaw;rate=8000 becomes audio%2Fmulaw%3Brate%3D8000. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

The text to synthesize. Specify either plain text or a subset of SSML. SSML is an XML-based markup language that provides text annotation for speech-synthesis applications. Pass a maximum of 5 KB of input text.

The Synthesize options.

The synthesize options.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

parameters

  • The text to synthesize.

  • The requested format (MIME type) of the audio. You can use the Accept header or the accept parameter to specify the audio format. For more information about specifying an audio format, see Audio formats (accept types) in the method description.

    Allowable values: [audio/basic,audio/flac,audio/l16,audio/ogg,audio/ogg;codecs=opus,audio/ogg;codecs=vorbis,audio/mp3,audio/mpeg,audio/mulaw,audio/wav,audio/webm,audio/webm;codecs=opus,audio/webm;codecs=vorbis]

    Default: audio/ogg;codecs=opus

  • The voice to use for synthesis.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified voice with no customization.

Response

Response type: io.ReadCloser

Response type: InputStream

Response type: NodeJS.ReadableStream|Buffer

Response type: file

Response type: String

Response type: Data

Response type: byte[]

Response type: byte[]

A binary file that contains the audio of the response.

Status Code

  • OK. The request succeeded.

  • Not Modified. The requested resource has not been modified since the time specified by the If-Modified-Since header, as documented in the HTTP specification.

  • Bad Request. A required input parameter is null or a specified input parameter or header value is invalid. If the request fails SSML validation, the description of the error explains the failure; for more information, see SSML validation.

  • Not Acceptable. The request specified an incompatible content type or failed to specify a required sampling rate.

  • Unsupported Media Type. The request specified an unacceptable media type.

  • Internal Server Error. The service experienced an internal error.

  • Service Unavailable. The service is currently unavailable.

No Sample Response

This method does not specify any sample responses.

Get pronunciation

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model.

Note: This method is currently a beta release.

See also: Querying a word from a language.

GET /v1/pronunciation
(textToSpeech *TextToSpeechV1) GetPronunciation(getPronunciationOptions *GetPronunciationOptions) (result *Pronunciation, response *core.DetailedResponse, err error)
ServiceCall<Pronunciation> getPronunciation(GetPronunciationOptions getPronunciationOptions)
getPronunciation(params, [callback()])
get_pronunciation(self, text, voice=None, format=None, customization_id=None, **kwargs)
get_pronunciation(text:, voice: nil, format: nil, customization_id: nil)
func getPronunciation(
    text: String,
    voice: String? = nil,
    format: String? = nil,
    customizationID: String? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<Pronunciation>?, WatsonError?) -> Void)
GetPronunciation(string text, string voice = null, string format = null, string customizationId = null)
GetPronunciation(Callback<Pronunciation> callback, string text, string voice = null, string format = null, string customizationId = null)
Request

Instantiate the GetPronunciationOptions struct and set the fields to provide parameter values for the GetPronunciation method.

Use the GetPronunciationOptions.Builder to create a GetPronunciationOptions object that contains the parameter values for the getPronunciation method.

Query Parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

The GetPronunciation options.

The getPronunciation options.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

parameters

  • The word for which the pronunciation is requested.

  • A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language (for example, en-US) return the same translation.

    Allowable values: [de-DE_BirgitVoice,de-DE_BirgitV3Voice,de-DE_DieterVoice,de-DE_DieterV3Voice,en-GB_KateVoice,en-GB_KateV3Voice,en-US_AllisonVoice,en-US_AllisonV3Voice,en-US_LisaVoice,en-US_LisaV3Voice,en-US_MichaelVoice,en-US_MichaelV3Voice,es-ES_EnriqueVoice,es-ES_EnriqueV3Voice,es-ES_LauraVoice,es-ES_LauraV3Voice,es-LA_SofiaVoice,es-LA_SofiaV3Voice,es-US_SofiaVoice,es-US_SofiaV3Voice,fr-FR_ReneeVoice,fr-FR_ReneeV3Voice,it-IT_FrancescaVoice,it-IT_FrancescaV3Voice,ja-JP_EmiVoice,ja-JP_EmiV3Voice,pt-BR_IsabelaVoice,pt-BR_IsabelaV3Voice]

    Default: en-US_MichaelVoice

  • The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the default format.

    Allowable values: [ibm,ipa]

    Default: ipa

  • The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the specified voice. If the word is not defined in the specified custom model, the service returns the default translation for the custom model's language. You must make the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see the translation for the specified voice with no customization.

Response

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

The pronunciation of the specified text.

Status Code

  • OK. The request succeeded.

  • Not Modified. The requested resource has not been modified since the time specified by the If-Modified-Since header, as documented in the HTTP specification.

  • Bad Request. A required input parameter is null or a specified input parameter or header value is invalid or not supported. Specific messages include

    • Invalid parameter '{name}' in request
    • Required parameter '{name}' is missing
    • Invalid header value for '{header}'
    • Invalid value for 'customization_id'
    • Customization language {language} does not match the language {language} for voice {voice}
  • Unauthorized. The specified customization_id is invalid for the requesting credentials:

    • Invalid customization_id ('{id}') for user
  • Not Found. The specified model was not found:

    • Model '{model}' not found
  • Not Acceptable. The request specified an Accept header with an incompatible content type.

  • Internal Server Error. The service experienced an internal error.

  • Service Unavailable. The service is currently unavailable.

Example responses

Create a custom model

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it.

Note: This method is currently a beta release.

See also: Creating a custom model.

POST /v1/customizations
(textToSpeech *TextToSpeechV1) CreateVoiceModel(createVoiceModelOptions *CreateVoiceModelOptions) (result *VoiceModel, response *core.DetailedResponse, err error)
ServiceCall<VoiceModel> createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions)
createVoiceModel(params, [callback()])
create_voice_model(self, name, language=None, description=None, **kwargs)
create_voice_model(name:, language: nil, description: nil)
func createVoiceModel(
    name: String,
    language: String? = nil,
    description: String? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<VoiceModel>?, WatsonError?) -> Void)
CreateVoiceModel(string name, string language = null, string description = null)
CreateVoiceModel(Callback<VoiceModel> callback, string name, string language = null, string description = null)
Request

Instantiate the CreateVoiceModelOptions struct and set the fields to provide parameter values for the CreateVoiceModel method.

Use the CreateVoiceModelOptions.Builder to create a CreateVoiceModelOptions object that contains the parameter values for the createVoiceModel method.

Custom Headers

  • The type of the input.

    Allowable values: [application/json]

A CreateVoiceModel object that contains information about the new custom voice model.

The CreateVoiceModel options.

The createVoiceModel options.

parameters

  • The name of the new custom voice model.

  • The language of the new custom voice model. Omit the parameter to use the the default language, en-US.

    Allowable values: [de-DE,en-GB,en-US,es-ES,es-LA,es-US,fr-FR,it-IT,ja-JP,pt-BR]

    Default: en-US