import requests
api_url = 'https://text-to-speech5.p.rapidapi.com/api/tts'
api_key = 'Your API Key'
params= {"tech": "deep", "text": "hello world.", "language": "en"}
header = {
"x-rapidapi-host": "text-to-speech5.p.rapidapi.com",
"x-rapidapi-key": api_key,
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(api_url, params=params, headers=header)
#download and save mp3 file on disk
with open("test.mp3", "wb") as f:
f.write(response.content)
####File output
If you get a http OK 200
message, you can download the audio file as a byte array
.