Audio

Create a speech

Changed on

Generate speech audio from text. Returns an audio file, or a stream of raw PCM chunks when stream is true. The body may be JSON or multipart/form-data — the latter lets you upload ref_audio as a raw file instead of base64-encoding it.

post/v1/audio/speech

Request

  • Base URL
    https://api.boson.ai
  • URL
    https://api.boson.ai/v1/audio/speech
  • Auth
    HTTP bearer

Request body

inputstring required

Text to convert to speech. Up to 5,000 characters, or 50,000 with stream: true; longer input returns 400 input_too_long. May contain inline control tags, which don't count toward this limit. Long input is split at natural boundaries and synthesized in full. With timestamps: true the input is not split; we recommend keeping it to roughly 300 characters.

model'higgs-tts-3'

TTS model ID / public alias. Resolved to the served model server-side.

voicestring

Preset voice name or custom voice ID. Mutually exclusive with ref_audio / ref_text when explicitly provided.

response_format'mp3' | 'opus' | 'pcm' | 'wav' | 'aac' | 'flac'

Output audio format. Streaming requires pcm.

streamboolean

If true, stream raw PCM chunks as they are decoded. Requires response_format to be pcm. Speed adjustment is not supported when streaming. Raises the input limit to 50,000 characters, so use it for long input.

ref_audiostring nullable

Inline reference audio for one-off cloning: an http(s) URL, data URI, or base64-encoded raw audio bytes. Supported formats: AAC, WAV, MP3, FLAC, OPUS. Inline (base64 / data-URI) payloads: max 10 MB.

ref_textstring nullable

Recommended transcript of ref_audio.

normalizeboolean

Expand non-standard words into spoken form before synthesis, including numbers, dates, times, currency, units, URLs, email addresses, phone numbers, abbreviations, and symbols. Enabled by default; set to false to synthesize the text exactly as written. Text with nothing to normalize is passed through unchanged. Inline tags are preserved. Replaces the deprecated enable_tn.

languagestring nullable

ISO 639-3 language code of the input text, for example eng (English) or cmn (Mandarin Chinese). Used for text normalization. Defaults to null, in which case normalization infers the language from the text; set it when you know the language for the most reliable results. An unsupported code returns 400 invalid_field_value, including when normalization is disabled. Replaces the deprecated tn_language field and ISO 639-1 codes such as en.

timestampsboolean

Attach word-level timestamps to the response. The response becomes a JSON envelope carrying the word list and the audio base64-encoded in the requested response_format, instead of raw audio bytes. Requires stream to be false; combining the two returns 400 timestamps_streaming_unsupported. Available for English, Chinese, and Spanish; other languages return a null word list. Overrides normalize, which does not run when timestamps are requested.

Example request

{
  "input": "Hello, this is a test."
}

Response

Generated audio. The content type depends on response_format. When timestamps is true the response is application/json instead, carrying the audio base64-encoded alongside the word list.

audiostring byte

Base64-encoded audio in the requested response_format. Decode it before writing it to a file.

response_format'mp3' | 'opus' | 'pcm' | 'wav' | 'aac' | 'flac'

Format of the encoded audio, echoing the requested response_format.

inputstring

The text the model was given, which the timestamps index into.

Changes

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      the request property's maxLength was increased from 5000 to 50000

    • info

      added the media type application/json for the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status