Treating the response as a WAV file
Treating the response as a WAV file
The body is headerless PCM. Writing it to
out.wav and double-clicking
fails or plays static. Convert it, or wrap it with a 44-byte WAV header in
code — see Playing the audio.Saving the response without checking the status
Saving the response without checking the status
On any error the body is JSON, not audio.
curl --output, wget -O or
open(f,"wb").write(r.content) will write that JSON into your .pcm file.
Converting it yields a silent 0-second clip — so a 400 shows up as “the
audio came back empty”.Use curl --fail-with-body, or check r.status_code / res.ok before
writing anything.Playing at the wrong sample rate
Playing at the wrong sample rate
It is 24000 Hz, mono, 16-bit LE. Playing it as 44100 makes it fast and
high-pitched; playing it as stereo makes it noise.Almost every “the audio sounds broken” report is one of these two.
Setting the wrong language
Setting the wrong language
Hindi text with
"language":"ta" is pronounced with Tamil rules and sounds
wrong — no error is raised. If unsure, or if the sentence mixes
languages, omit the field rather than guessing.Misspelling the voice
Misspelling the voice
Only
Ananya and Arjun exist. "Ananaya" returns 400 rather than
silently substituting, so you are never billed for audio in a voice you did
not ask for.Buffering the whole response before playing
Buffering the whole response before playing
Discards the streaming advantage entirely — 120 ms becomes 730 ms. Play
chunks as they arrive.
Opening a new connection per request
Opening a new connection per request
Pays the TLS handshake every time: ~300 ms, on every call.
Putting the key in browser JavaScript
Putting the key in browser JavaScript
Anything shipped to a browser is public. Call from your server, and proxy if
a browser needs the audio.
Retrying a 400 or 401
Retrying a 400 or 401
Deterministic — the same request fails identically forever. Only 502 and 5xx
are worth retrying.
An unexpected 403
An unexpected 403
A
403 whose body is not JSON did not come from us. It is a request
filter reacting to your HTTP client’s default User-Agent. Setting any
User-Agent clears it — see Errors.