POST Text to speech
Turns text into natural speech. Choose from the published Bambara voices, or an international voice. Response: an audio file WAV.
POST/v1/audio/speech
Body JSON. Required permission: tts.
Turns text into natural speech. Choose from the published Bambara voices, or an international voice. Response: an audio file WAV.
Body JSON. Required permission: tts.
| Name | Type | Description |
|---|---|---|
inputrequired | string | The text to speak (5,000 characters max). |
voiceoption | string | Voice identifier (see Voices). Default modibo. |
tgtoption | string | Language of the text / voice (see Languages). Default bam_Latn. |
srcoption | string | Translate the text before speaking it: source language, or auto. Default same (no translation). |
speedoption | number | Speaking rate, from 0.5 to 2.0. Absent = 1.0 (same output as the Studio). |
response_formatoption | string | Output audio format. wav (default, lossless — recommended, same as the Studio) or mp3 (128 kbps mono). |
The body is the audio file raw (Content-Type: audio/wav), not JSON. Write it straight to disk.
Billed per character. Custom (cloned) voices are billed at a higher rate.
curl https://api.kooma.ai/v1/audio/speech \
-H "Authorization: Bearer sk-intermo-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "I ni ce, i ka kɛnɛ wa?",
"voice": "aminata",
"tgt": "bam_Latn",
"speed": 1.0
}' \
--output sortie.wav
import requests
r = requests.post(
"https://api.kooma.ai/v1/audio/speech",
headers={"Authorization": "Bearer sk-intermo-YOUR_KEY"},
json={
"input": "I ni ce, i ka kɛnɛ wa?",
"voice": "aminata",
"tgt": "bam_Latn",
},
)
open("sortie.wav", "wb").write(r.content)
const r = await fetch("https://api.kooma.ai/v1/audio/speech", {
method: "POST",
headers: {
"Authorization": "Bearer sk-intermo-YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
input: "I ni ce, i ka kɛnɛ wa?",
voice: "aminata",
tgt: "bam_Latn",
}),
});
const wav = await r.arrayBuffer();
RIFF....WAVEfmt ............ # audio file
{
"error": {
"message": "Insufficient prepaid credits for 'tts'.",
"type": "insufficient_credits",
"code": "insufficient_credits"
}
}