External API
Turn text into speech
Turn any text into a spoken recording, in a choice of voice, speed and audio format.
Turns text into a spoken recording – for example, a message to play on your phone line. Proto replies with the audio file. Each request uses 1 voice credit, however long the text – you can see your credits in Settings, under Workspace, then Voice API. Not sure how to send a request? See Make your first request.
Request
Send a POST request to:
https://v3-api.proto.cx/api/platform/v1/voice/YOUR_TEAMSPACE_ID/tts
In the body, send the text and how it should sound. In the address, replace anything starting with YOUR_ with your own:
{
"text": "Thank you for calling. All our live agents are busy. Please stay on the line.",
"lang": "en",
"response_format": "mp3",
"gender": "female",
"speed": 1,
"instructions": "Calm and slow, like a radio presenter"
}
| Field | Required | What it is |
|---|---|---|
text | Yes | What to say – up to 5,000 characters |
lang | Yes | The text’s language, as a code such as en, fr, sw or rw |
response_format | No | mp3, wav, opus, aac or flac. Defaults to opus. |
gender | No | male or female. Defaults to male. |
speed | No | From 0.25 to 4. Defaults to 1. |
instructions | No | How the voice should sound. Defaults to a warm, professional customer service voice. It doesn’t apply to rw or kj. |
Kinyarwanda (rw) and Oshiwambo (kj) use Proto’s own voices. Other languages are spoken in the language the text is written in.
Response
Proto replies 200 OK with the recording itself, not JSON, in the format you asked for. Save it as a file – such as greeting.mp3 – and play it to check it. The Content-Type header is audio/ followed by the format, such as audio/mp3, and Content-Length is the recording’s size in bytes.
Errors
If a request fails after Proto takes the credit, the credit is given back.
| You get | What it means |
|---|---|
400 | The voice for rw or kj isn’t available right now. Try again later. |
403 | Your workspace has no voice credits left. Top up in Voice API, on the Billing tab. |
422 | The text is empty or too long, or the language, format, gender or speed isn’t one Proto accepts. |
504 | The recording took too long to make. Try shorter text. |
For errors any request can return, see If something goes wrong.