Synthesize Text
  • 28 May 2024
  • 1 Minute to read
  • Contributors
  • PDF

Synthesize Text

  • PDF

Article summary

Allows you to synthesize text into spoken audio and retrieve the synthesized audio stream as an array of bytes.

Endpoint Details

  • URL: {{Address}}/v1/speech/synthesis/tts
  • HTTP Method: POST
  • HTTP Request: POST v1/speech/synthesis/tts
  • Summary: Synthesizes text to spoken audio.
  • Request: JSON Format.

Query Parameters (Optional)

You have the option to query available voices based on culture and gender using query parameters. For example:

  • {{Address}}/v1/speech/synthesis/voices/?language=tr-TR&gender=female

Request Fields Descriptions

Request:

  • Text: The text to be synthesized (plain text).
  • Name: Speaker name.
  • Volume: The base volume (loudness) level of the voice. Range is 0.0-2.0.
  • Rate: The speaking rate of the voice. Range is 0.33-3.0.
  • Format: Audio output format.
  • Sample Rate: Audio output sample rate.
  • Authorization: Bearer token for licensing.

Request Examples

Request Example for WAV File:

{
  "Text": "Hello World",
  "Voice": {
    "Name": "Emily",
    "Volume": 1.0,
    "Rate": 1.0
  },
  "Audio": {
    "Format": "wav",
    "FormatDetails": {
      "Encoding": "pcm",
      "SampleRate": "8000"
    }
  }
}

Request Example for Opus File:

{
  "Text": "Hello World",
  "Voice": {
    "Name": "Emily",
    "Volume": 1.0,
    "Rate": 1.0
  },
  "Audio": {
    "Format": "opus",
    "FormatDetails": {
      "BitRateKbps": "8",
      "SampleRate": "8000"
    },
  }

Response

The response returns the audio stream for the specified text as an array of bytes in the specified MIME type: WAV, Opus, MP3, FLV.

Response Codes

StatusDescription
200 OKThe request succeeded.
500 Internal Server ErrorThe service experienced an internal error.
400 Bad RequestRequired request parameter value is not valid or not supported.
404 Not FoundRequested voice is not found.
412 Precondition FailedCloud License parameters are invalid or requested voice is not licensed or license credits are consumed completely.
422 Unprocessable EntityBit rate or sample rate is invalid, or an 8k voice is requested instead of a 16k voice.

Failure Response Example:

{
  "errorCode": "http-404",
  "errorMessage": "Unknown voice name",
  "moreInfo": "",
  "success": false
}

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.