curl -X POST https://api.brainiall.com/v1/tts/synthesize \
-H "Authorization: Bearer $BRAINIALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello from Brainiall Speech engine.", "voice": "en-US-aurora"}' \
--output speech.wav
Exemple avec la bibliothèque standard pour la synthèse par lots et l'exportation de fichiers.
import os
import json
import urllib.request
API_URL = "https://api.brainiall.com/v1/tts/synthesize"
def synthesize(text: str, voice: str = "en-US-aurora", output_path: str = "output.wav"):
payload = json.dumps({
"text": text,
"voice": voice
}).encode("utf-8")
req = urllib.request.Request(
API_URL,
data=payload,
headers={
"Authorization": f"Bearer {os.environ['BRAINIALL_API_KEY']}",
"Content-Type": "application/json"
},
method="POST"
)
with urllib.request.urlopen(req) as response:
with open(output_path, "wb") as f:
f.write(response.read())
print(f"Speech saved to {output_path}")
# synthesize("Natural voice synthesis via Brainiall API", voice="en-US-aurora")