SAGEA LogoDocs & API
CookbooksVoice Cookbooks

IVR Prompt Pack with Sonus

Convert a CSV of IVR prompts into telephony-ready WAV audio with POST https://api.sagea.space/v1/batch.

  • Load prompts from CSV and validate length
  • Batch synthesize to wav 16kHz mono
  • Write a filename manifest for your IVR system

Time to complete: ~20 minutes

Prerequisites

  • Python 3.9+ with pip install requests.
  • ffmpeg and ffprobe for sample-rate checks.
  • A SAGEA API key exported as SAGEA_API_KEY.
  • Read Synthesize speech with Sonus for voices and formats.
  • Skim the Sonus TTS model card for rate limits and pricing.

Step 1: Prepare the prompt CSV

Create prompts.csv with id and text columns. Keep every row under 4096 chars.

cat prompts.csv
awk -F',' '{ print length($0)" "$1 }' prompts.csv

Example rows are welcome, menu, hours, and fallback. Use professional emotion for phone audio.

Step 2: Batch synthesize to WAV

Send all prompts in one POST https://api.sagea.space/v1/batch call with endpoint set to /v1/audio/speech. Batch gets a 50 percent discount.

curl -X POST https://api.sagea.space/v1/batch \
  -H "Authorization: Bearer $SAGEA_API_KEY" -H "Content-Type: application/json" \
  -d '{"endpoint": "/v1/audio/speech", "requests": [{"model": "sonus-tts", "input": "Thank you for calling Acme.", "voice": "nova", "response_format": "wav", "emotion": "professional", "speed": 1.0}, {"model": "sonus-tts", "input": "Press 1 for sales. Press 2 for support.", "voice": "nova", "response_format": "wav", "emotion": "professional", "speed": 1.0}]}'

If batch is async, poll the returned batch_id until status is completed.

Step 3: Normalize to 16kHz mono and write a manifest

IVR systems expect WAV 16kHz mono. Convert and emit manifest.csv:

for f in welcome.wav menu.wav hours.wav fallback.wav; do [ -f "$f" ] && ffmpeg -y -i "$f" -ar 16000 -ac 1 -c:a pcm_s16le "ivr_$f"; done
ffprobe -v error -show_entries stream=codec_name,sample_rate,channels -of default=noprint_wrappers=1 ivr_welcome.wav
# manifest.py
import csv, pathlib
wavs = sorted(pathlib.Path(".").glob("ivr_*.wav"))
w = csv.writer(open("manifest.csv", "w", newline="", encoding="utf-8"))
w.writerow(["prompt_id", "filename", "sample_rate_hz", "channels"])
for p in wavs:
    w.writerow([p.stem.replace("ivr_", ""), p.name, 16000, 1])
print(f"Wrote manifest.csv with {len(wavs)} rows")

Limits are 50 req per min on Starter and 500 on Pro, so batch is preferred.

Verify

Every ivr_*.wav should report 16000 Hz and 1 channel. If a call fails, check the error table below.

ErrorCauseFix
401 UnauthorizedAPI key missing or invalidRe-export SAGEA_API_KEY with a valid key
400 text_too_longA prompt exceeds 4096 charsShorten that row and resubmit only that prompt
422 voice_not_foundVoice name is wrongUse nova or a valid voice_id starting with vox_
429 rate_limit_exceededOver 50 req per min on Starter, 500 on ProUse the batch endpoint and retry with backoff

What's next

On this page