Audio & TTS

Zend voice calls play one of two things: a message rendered with neural text-to-speech, or your own hosted audio recording. This page covers how to get the most from TTS and how to upload your own audio.

Pick your audio source per send — set text for TTS or voice_url for a recording, never both. See Send Voice for the full request.

Text-to-speech tips

Pass text and Zend converts it to natural speech. Keep it under 600 characters — roughly under a minute of audio.

Note

Digit sequences of 4 or more — OTPs, phone numbers — are read out digit-by-digit at a slower pace, so verification codes come through clearly. Currency amounts like "GHS 500" are read naturally.
{
  "recipients": ["233XXXXXXXXX"],
  "text": "Hello, this is a call from Zend. Your verification code is 4821.",
  "voice": "female"
}

Voice options

The voice field selects the TTS voice. It only applies to text-to-speech sends and is ignored when you use voice_url.

voicestring
female (default) or male.

Upload an audio file

To play your own recording, set voice_url to a public https URL for an mp3 or wav file, up to 10 MB. Zend stores a copy and delivers it.

If you don't have public hosting for your audio, upload it to Zend first and use the returned url as voice_url.

POST/voice/upload

Accepts a multipart file field, mp3 or wav, up to 10 MB.

curl -X POST https://api.tryzend.com/voice/upload \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@announcement.mp3"

Response

{
  "url": "https://storage.googleapis.com/zend-2d42e.firebasestorage.app/voice-audio/uploads/68a1...-b2c3.mp3",
  "path": "voice-audio/uploads/68a1...-b2c3.mp3",
  "size": 482913
}

Then send the call with that url. When using voice_url, fallback.sms_text is required if you enable SMS fallback, since there's no spoken text to fall back to.

curl -X POST https://api.tryzend.com/voice/send \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipients": ["233XXXXXXXXX"],
    "voice_url": "https://storage.googleapis.com/zend-2d42e.firebasestorage.app/voice-audio/uploads/68a1...-b2c3.mp3",
    "fallback": {"sms": true, "sms_text": "You have a new voice announcement from Zend."}
  }'

Next steps