import requests
DEEPINFRA_TOKEN = "$DEEPINFRA_TOKEN"
MODEL = "hexgrad/Kokoro-82M"
response = requests.post(
f"https://api.deepinfra.com/v1/inference/{MODEL}",
headers={
"Authorization": f"Bearer {DEEPINFRA_TOKEN}",
"Content-Type": "application/json",
},
json={
"text": "Hello! This is a text-to-speech example using DeepInfra.",
},
)
# Save the returned audio
with open("output.wav", "wb") as f:
f.write(response.content)