Text to Speech API
This page explains how to interact with the standalone Text-to-Speech (TTS) API to generate audio from a given transcript, using a selected voice from the available voice list.
Last updated
Was this helpful?
Was this helpful?
import requests
import json
url = "https://api.convai.com/tts/"
payload = json.dumps({
"transcript": "In the quiet of the morning, as the sky turned shades of pink and orange, she walked along the path lined with blooming flowers, feeling the cool breeze on her face. It was finally time for dinner.",
"voice": "fable_OpenAi_c4d30a32-bcaf-4048-b7b0-0f2bb293205a",
"encoding": "wav"
})
headers = {
'CONVAI-API-KEY': '<Your Convai API Key>',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
if response.status_code == 200:
with open('audio.wav','wb') as f:
f.write(response.content)
else:
print(response.text)