# Generate a voiceover from a Python script, with word timings for captions

From Python this is one requests.post to the RouterGrowth run endpoint: capability creative.speech and your script as input. Read audio.url and download the file. Set timestamps to true and the same result lists each word with its start and end, which is what captions need. No SDK to install beyond an HTTP client.

HTML page: https://www.routergrowth.com/tools/ai-creative/text-to-speech-api-python
Part of: [AI creative tools](https://www.routergrowth.com/tools/ai-creative.md)

## The call

[`creative.speech`](https://www.routergrowth.com/catalog/creative.speech): Turn a script into a natural voiceover for ads, product videos and prospect films, with ElevenLabs voices.

Price on this network: $0.0875 per 1k characters. The exact quote is shown before every run.

## What a real run returned

Run on 2026-11-02: 1 records in 1.2 s for $0.02. Personal fields are masked. A 200 character weekly update returned an MP3 and 39 word timings ending at 14.3 seconds; one word came back split in two, table as tabl and e, so captions need a cleanup pass.

| voice | characters | file_size | timings | last_word_end |
|---|---|---|---|---|
| Daniel | 200 | 232429 | 39 | 14.303 |

## How to do it

1. **Keep the key out of the code.** Read the RouterGrowth key from an environment variable and send it as a Bearer header.
2. **POST the script.** Body: capability creative.speech, input with text, voice, model and timestamps. requests or httpx both work.
3. **Download the audio.** Read result.audio.url and save the bytes to disk straight away, since the URL is temporary.
4. **Build captions.** Loop over result.timestamps, each with word, start and end, and group them into caption lines.

## Ask it like this

- Write me a Python script that voices each line of this text file with creative.speech and saves one MP3 per line. (`creative.speech`)
- Voice this script with timestamps on and turn the word timings into an SRT caption file. (`creative.speech`)

## Connect

MCP server: `https://api.routergrowth.com/mcp`

```bash
claude mcp add --transport http routergrowth https://api.routergrowth.com/mcp
```

```bash
npm install -g routergrowth && routergrowth setup
routergrowth run -c creative.speech -i '{"text": "Welcome back to the weekly numbers. Signups rose a little, churn stayed flat, and support tickets fell for the third week in a row. The full table is in the notes, and the next update lands on Monday.", "voice": "Daniel", "model": "eleven-turbo", "timestamps": true}'
```

```bash
curl -X POST https://api.routergrowth.com/v1/run \
  -H "Authorization: Bearer $ROUTERGROWTH_API_KEY" \
  -d '{"capability": "creative.speech", "input": {"text": "Welcome back to the weekly numbers. Signups rose a little, churn stayed flat, and support tickets fell for the third week in a row. The full table is in the notes, and the next update lands on Monday.", "voice": "Daniel", "model": "eleven-turbo", "timestamps": true}}'
```

## Worth knowing

- **Merge split words.** In this run one word came back as two timing entries. Compare against your script when you build captions.
- **Long scripts need chunks.** Each call takes up to 5,000 characters, so a loop has to split on sentence ends and join the audio.
- **Timestamps are opt in.** They are off by default. Without them the result holds the audio and the character count only.

## Questions

### Is there a Python package to install?

None is needed. The API takes JSON, so any HTTP client works.

### Does it stream audio?

The result gives a URL to a finished file. Streaming is not part of this call.

### Can I voice many lines in one script?

Each call is its own run, so a loop can send one per line. Budget for the total characters, since the charge follows length.

### Which voice names can I pass?

The ones the catalog lists, such as Daniel, Aria, George or Lily. Omit voice for the model's default.

## Related

- [Generate a Flux image from a text prompt without a fal account](https://www.routergrowth.com/tools/ai-creative/flux-api.md)
- [Turn a short script into an MP3 with one call and one key](https://www.routergrowth.com/tools/ai-creative/text-to-speech-api.md)
- [Send an image URL and get back the subject on a transparent PNG](https://www.routergrowth.com/tools/ai-creative/background-removal-api.md)
- [Generate an image from a prompt, and switch models with one input](https://www.routergrowth.com/tools/ai-creative/ai-image-generation-api.md)
