Skip to main content
POST
Stream speech with word timings

Authorizations

Authorization
string
header
required

Your AssemblyAI API key, or a temporary token, in the Authorization header. The raw key works directly; a Bearer prefix is also accepted, which is what OpenAI SDKs send. Send exactly one Authorization header. The HTTP routes read the credential from this header only.

Headers

X-Client-Request-Id
string

Your own id for the request, 1 to 512 printable ASCII characters. It is echoed in the response and kept with the request's records. It need not be unique; X-Request-Id is the unique key. An invalid value is ignored and not echoed.

Required string length: 1 - 512

Body

application/json

The body of Create speech without its file formats. The audio is raw pcm_s16le, pcm_mulaw or pcm_alaw; encoding mp3, container wav, bit_rate and stream false are refused.

text
string
required

The text to speak, 1 to 5,000 Unicode code points; see SpeechRequest.

Required string length: 1 - 5000
voice_id
string

The voice, by its library slug such as aai-jane, its ID or the slug of one of your account's voices; see SpeechRequest.

Required string length: 1 - 64
model_id
string

The name of the model to speak with; see SpeechRequest.

Required string length: 1 - 48

true renews the biometric consent of the cloned voice in voice_id, by the voice's owner only; see SpeechRequest. The Termination event carries the expiry after the renewal.

language
enum<string>

The language to speak, as its full name, case-insensitive; see SpeechRequest.

Available options:
english,
spanish,
german,
italian,
portuguese,
french
sample_rate
enum<integer>
default:24000

The sample rate of the audio in Hz.

Available options:
8000,
16000,
22050,
24000,
44100,
48000
encoding
enum<string>
default:pcm_s16le

The encoding of the audio in the Audio events, case-insensitive.

Available options:
pcm_s16le,
pcm_mulaw,
pcm_alaw,
mulaw,
alaw
container
enum<string>
default:raw

raw only, case-insensitive: the events carry raw samples, and wav is refused.

Available options:
raw
word_boundaries
boolean
default:true

false leaves out the WordBoundaries event; Termination.word_boundaries_status is then disabled.

speed
number

Accepted when it equals 1; any other value is refused.

Response

The event stream.

Server-sent events: Begin, Audio, FlushDone, WordBoundaries, Termination and Error. Their data objects are described under SpeechBeginEvent, SpeechAudioEvent, SpeechFlushDoneEvent, SpeechWordBoundariesEvent, SpeechTerminationEvent and SpeechErrorEvent.