The Text to Speech (TTS) service converts written text into spoken audio in various Ugandan languages.
Available Voices
We provide specific speaker models for each language to ensure natural intonation and pronunciation.
| ID | Language | Gender | Characteristics |
|---|
| 241 | Acholi | Female | Clear, moderate pace |
| 242 | Ateso | Female | Warm, expressive |
| 243 | Runyankole | Female | Soft, natural |
| 245 | Lugbara | Female | Clear articulation |
| 246 | Swahili | Male | Deep, authoritative |
| 248 | Luganda | Female | Natural, conversational |
Generating Speech
Use the /tasks/tts endpoint.
Parameters
| Parameter | Type | Required | Description |
|---|
text | string | Yes | The text to convert to speech. |
speaker_id | integer | Yes | The ID of the voice to use (see table above). |
Example Request
Generating Luganda speech.
import requests
url = "https://api.sunbird.ai/tasks/tts"
payload = {
"text": "Oli otya?",
"speaker_id": 248
}
headers = {
"Authorization": "Bearer <YOUR_TOKEN>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Response
The response includes a URL to the generated audio file.
{
"output": {
"audio_url": "https://storage.googleapis.com/...",
"sample_rate": 16000
}
}
The audio_url is a temporary signed URL. You should download or stream the audio immediately.