import requests
# Using default voice (voice_id is optional)
response = requests.post(
'https://dev.voice.ai/api/v1/tts/speech/stream',
headers={'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
json={'text': 'This is a test of streaming audio generation.'},
stream=True
)
# Or with a custom voice_id:
# json={'voice_id': 'your-voice-id-here', 'text': 'This is a test of streaming audio generation.'}
with open('output.mp3', 'wb') as f:
for chunk in response.iter_content():
if chunk: f.write(chunk)