Skip to navigation

REST Stream

View as Markdown

Convert text into spoken audio and stream it back as it is generated. The response is a binary audio stream (Transfer-Encoding: chunked) that you can play or save directly, with no base64 decoding. The default format is MP3 (audio/mpeg). Set output_audio_codec to change it.

Models

ModelSpeakersDefault speaker
bulbul:v4-flash200+ persona IDs such as simran_en_customershubh_enhi_ads
bulbul:v3 (API default when model is omitted)37 names such as shubhshubh

Both models use the same request format and accept the same parameters, languages and limits.

Differences from POST /text-to-speech

/text-to-speech/stream/text-to-speech
Max text3,500 characters2,500 characters
ResponseRaw audio streamJSON with base64 audio
Default codecmp3wav
Sample rates8000, 16000, 22050, 24000 HzAlso 32000, 44100, 48000 Hz
output_audio_bitrateSupportedNot supported

Only text is required. Supports the dict_id parameter to apply a pronunciation dictionary.

Authentication

api-subscription-keystring
API Key authentication via header

Request

This endpoint expects an object.
textstringRequired1-3500 characters

The text to convert into speech, up to 3,500 characters. Code-mixed text (English and Indic languages) is supported. Write Indic words in their native script for the best quality.

language_codeenumOptional

The language of the text, as a BCP-47 code. Both models accept all 11 codes. Default: en-IN. The language also guides the text normalization applied before synthesis.

speakerenum or nullOptional

The voice to use. Speaker names are case-sensitive and lowercase, and must match the chosen model. If omitted, the model default is used: shubh for bulbul:v3, shubh_enhi_ads for bulbul:v4-flash.

A speaker that does not match the model returns a 400 that lists the valid speakers. See the Voices guide for the speaker lists.

pitchdouble or nullOptional-0.5-0.5

Controls the pitch of the audio. Lower values give a deeper voice and higher values a sharper one. Range: -0.5 to 0.5. Default: 0.0. Values outside the range return a 400.

pacedouble or nullOptional0.5-2Defaults to 1

Controls the speed of the audio. Lower values give slower speech and higher values faster speech. Range: 0.5 to 2.0. Default: 1.0. Values outside the range return a 400.

loudnessdouble or nullOptional0.1-2.5

Controls the loudness of the audio. Lower values are quieter and higher values louder. Range: 0.1 to 2.5. Default: 1.0. Values outside the range return a 400.

speech_sample_rateenum or nullOptionalDefaults to 22050

The sample rate of the output audio in Hz. Default: 22050. Streaming accepts 8000, 16000, 22050 and 24000. Higher rates (32000, 44100, 48000) return a 400; use the REST API for those.

opus works at 8000, 16000 and 24000 Hz. At 22050 Hz it returns a 400.

enable_preprocessingbooleanOptionalDefaults to false

Normalizes English words and numeric entities (such as numbers and dates) before synthesis. Accepted on both models. Default: false.

modelenumOptional

The model to use.

  • bulbul:v4-flash: the latest model, recommended for new integrations. Same request format as bulbul:v3, with 200+ persona voices.
  • bulbul:v3: the API default when model is omitted. 37 named speakers.
Allowed values:
temperaturedouble or nullOptional0.01-1Defaults to 0.6

Controls how much randomness and expressiveness the model uses. Lower values give steadier, more consistent speech. Higher values sound more expressive but can introduce artifacts. Range: 0.01 to 1.0. Default: 0.6.

enable_cached_responsesbooleanOptionalDefaults to false

Beta. Requests caching for identical requests. Behavior is not guaranteed, and identical requests can still return newly generated audio. Default: false.

dict_idstring or nullOptional

The ID of a pronunciation dictionary to apply. Matching words in the text are replaced with their custom pronunciations before synthesis. Format: p_ followed by 8 hex characters. Supported on both models.

Create and manage dictionaries with the Pronunciation Dictionary API. On this endpoint an unknown ID returns a 500 (“error preprocessing input text”), so confirm the ID exists before you stream.

output_audio_codecenumOptional

The audio format of the streamed response. Default: mp3. Content types: mp3 audio/mpeg, wav audio/wav, aac audio/aac, flac audio/flac, linear16 audio/pcm, mulaw audio/mulaw, alaw audio/alaw, opus audio/opus.

output_audio_bitrateenumOptional

The bitrate of the streamed audio. One of 32k, 64k, 96k, 128k or 192k. Default: 128k. Other values (such as 256k) return a 400.

Allowed values:

Response

Success. Returns a chunked audio stream. The Content-Type matches output_audio_codec (audio/mpeg for the default MP3).

Errors

400
Bad Request Error
403
Forbidden Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error