Skip to content
Docs

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"
}
FieldRequiredWhat it is
textYesWhat to say – up to 5,000 characters
langYesThe text’s language, as a code such as en, fr, sw or rw
response_formatNomp3, wav, opus, aac or flac. Defaults to opus.
genderNomale or female. Defaults to male.
speedNoFrom 0.25 to 4. Defaults to 1.
instructionsNoHow 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 getWhat it means
400The voice for rw or kj isn’t available right now. Try again later.
403Your workspace has no voice credits left. Top up in Voice API, on the Billing tab.
422The text is empty or too long, or the language, format, gender or speed isn’t one Proto accepts.
504The recording took too long to make. Try shorter text.

For errors any request can return, see If something goes wrong.

Stuck? Ask Advisor in the Proto dashboard, or contact us.

© Proto