Luke Oliff.

TIL: Test TTS Voices With Curl

·TIL·3 min read·Luke Oliff

The fastest way to test a TTS voice is a single curl command that pipes audio straight to a file, no SDK or dashboard needed. I learned this the hard way after setting up a full integration just to hear whether a voice parameter did what I expected.

curl -s -X POST "https://api.speechify.ai/v1/audio/speech" \
  -H "Authorization: Bearer $SPEECHIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "The quick brown fox jumps over the lazy dog. That sentence is a pangram, which means it contains every letter of the alphabet. Handy for hearing how a voice handles the full phonetic range.",
    "voice_id": "george",
    "audio_format": "mp3"
  }' \
  --output test-george.mp3

Swap the voice_id, change the input text, run it again. I keep a shell script with a handful of voice IDs and run them in a loop to A-B compare. No browser, no state, no cache.

Which TTS parameters should you test with curl?

The voice ID is obvious but the parameters that actually change the output are less so. A JSON payload can carry speed, pitch, emphasis, SSML, and model version. The fastest way to test any of them is the same pattern: change one variable per request, pipe to a new filename, listen back to back.

# Compare speed
for speed in 0.8 1.0 1.2; do
  curl -s -X POST "https://api.speechify.ai/v1/audio/speech" \
    -H "Authorization: Bearer $SPEECHIFY_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"input\":\"Testing at speed $speed.\",\"voice_id\":\"george\",\"audio_format\":\"mp3\",\"speed\":$speed}" \
    --output "test-speed-$speed.mp3"
done

The same trick works for SSML tags, voice personality parameters, or different model tiers. Curl keeps everything stateless and explicit. No hidden state from a dashboard session.

Why I use curl over SDKs for voice testing

Three weeks into a TTS role I learned that most voice quality issues I was debugging turned out to be things I would have heard in the first five seconds with curl. A misconfigured rate limit, a voice model that sounded different at certain speeds, an SSML tag that one provider interpreted differently from another. The integration code was fine. The parameters were wrong. And I could have known that before writing the first line of it.

FAQ

Can I use curl with other TTS APIs?

Yes. Most TTS APIs follow the same POST pattern. Swap the endpoint URL, auth header, and parameter names. The curl workflow is the same.

What if the API returns a binary response?

That is expected. Most TTS APIs return raw audio bytes. The --output flag in curl writes them directly to a file. Play it with any media player.

Is this faster than using an SDK?

For testing and exploration, yes. An SDK adds setup, imports, and object instantiation before you hear audio. Curl is one command. For production, use the SDK. For figuring out whether “george” sounds better at speed 1.1 or 1.2, curl wins every time.