import requestsimport base64url = "https://api.hyperbolic.xyz/v1/audio/generation"headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY"}data = { "text": "Welcome to Hyperbolic! This is an example of text-to-speech generation.", "speed": 1}response = requests.post(url, headers=headers, json=data)result = response.json()# Decode and save the audio fileaudio_data = base64.b64decode(result["audio"])with open("output.mp3", "wb") as f: f.write(audio_data)
curl -X POST "https://api.hyperbolic.xyz/v1/audio/generation" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "text": "Welcome to Hyperbolic! This is an example of text-to-speech generation.", "speed": 1 }' | jq -r ".audio" | base64 -d > output.mp3
import base64def save_audio(response_json, filename="output.mp3"): """Decode and save the generated audio.""" audio_data = base64.b64decode(response_json["audio"]) with open(filename, "wb") as f: f.write(audio_data)
# Slow narration for accessibilitydata = { "text": "Please listen carefully to the following instructions.", "speed": 0.7}# Fast playback for quick reviewdata = { "text": "This is a quick summary of the key points.", "speed": 1.5}
Use slower speeds (0.5-0.8) for instructional content or accessibility needs. Use faster speeds (1.2-1.5) for content review or when listeners prefer quicker playback.