Mansa Platform Docs

TTS (Text-to-Speech)

Synthesize text into spoken WAV audio across African languages and English.

POST/v1/tts

Request example

curl --fail-with-body "$MANSA_API_BASE_URL/v1/tts" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Good morning. Welcome to our platform.",
  "language": "english",
  "voice": "ghanaian_female"
}' \
  --output speech.wav

Output

HTTP/1.1 200 OK
Content-Type: audio/wav

(binary WAV audio; save the response body to speech.wav)

Synthesize text into spoken speech audio across African languages and English. Audio is generated using CosyVoice3 models with support for authentic native speaker regional accents.


Authentication

All requests require Bearer token authentication in the HTTP header:

Authorization: Bearer <YOUR_API_KEY>

Endpoint Overview

POST /v1/tts

Converts input text into spoken binary WAV audio.

[!NOTE] The platform also supports POST /v1/speech and OpenAI-compatible POST /v1/audio/speech as route aliases for backward compatibility.


Request Fields (application/json)

FieldTypeRequiredDefaultDescription
textStringYes—Non-empty text to convert to spoken audio (maximum 8,000 characters).
languageStringYes—A supported language name (e.g. English, Swahili) or lowercase slug (english, swahili).
voiceStringNonigerian_femaleAn optional supported voice identifier.
streamBooleanNofalseWhen true, streams progressive audio chunks as they are synthesized.
formatStringNo"wav"Audio container format: "wav" (default) or "pcm".

Streaming Audio

You can receive speech progressively using any of the following methods:

  1. In the Request Body: Pass "stream": true in your JSON payload.
  2. Via Query Parameter: Append ?stream=true (e.g., POST /v1/tts?stream=true).
  3. Dedicated Streaming Route: Send your request to POST /v1/tts/stream.
  4. Via Accept Header: Set Accept: audio/wav.

Response Structure

1. Unary Mode (stream: false)

Returns a complete binary WAV file with Content-Type: audio/wav. You can stream or save the binary body directly into an .audio.wav file.

Response Headers

  • Content-Type: audio/wav
  • X-Duration-Sec: Estimated duration of the synthesized audio in seconds.
  • X-Sampling-Rate: Audio sampling rate (e.g., 24000 Hz).
  • X-Language: Canonical language slug used for synthesis.
  • X-Credits-Consumed: Mansa credits charged for the request.
  • X-Credits-Remaining: Remaining credit balance in your account.

2. Streaming Mode (stream: true)

Returns audio chunks with Content-Type: audio/wav as progressive binary data streams over HTTP.


Example Requests

Unary Synthesis (cURL)

curl -X POST https://api.mansa.ai/v1/tts \
  -H "Authorization: Bearer mansa_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Good morning. Welcome to our platform.",
    "language": "english",
    "voice": "ghanaian_female"
  }' \
  --output speech.wav

Progressive Streaming (cURL)

curl -X POST https://api.mansa.ai/v1/tts \
  -H "Authorization: Bearer mansa_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Good morning. Streaming speech synthesis allows immediate playback.",
    "language": "english",
    "voice": "nigerian_male",
    "stream": true
  }' \
  --output streaming_speech.wav

Voice Catalog

Every supported language accepts binary "male" and "female" options. When omitted, the voice defaults to nigerian_female.

1. Regional English Accents

When language is set to english, you can specify regional African English accents:

  • nigerian_male & nigerian_female (West Africa)
  • ghanaian_male & ghanaian_female (West Africa)
  • east_african_male & east_african_female (East Africa)
  • north_african_male & north_african_female (North Africa)
  • south_african_male & south_african_female (Southern Africa)

2. Native Speaker English Accents

Each of the 37 African languages also provides native speaker accent voices named {language}_{gender}_speaker (speaking English with that language's authentic native speaker inflection):

RegionLanguageMale VoiceFemale Voice
West AfricaIgboigbo_male_speakerigbo_female_speaker
West AfricaYorubayoruba_male_speakeryoruba_female_speaker
West AfricaHausahausa_male_speakerhausa_female_speaker
West AfricaTwitwi_male_speakertwi_female_speaker
West AfricaKanurikanuri_male_speakerkanuri_female_speaker
West AfricaFulafula_male_speakerfula_female_speaker
West AfricaEweewe_male_speakerewe_female_speaker
West AfricaFonfon_male_speakerfon_female_speaker
West AfricaBambarabambara_male_speakerbambara_female_speaker
West AfricaWolofwolof_male_speakerwolof_female_speaker
West AfricaKriokrio_male_speakerkrio_female_speaker
East AfricaSwahiliswahili_male_speakerswahili_female_speaker
East AfricaKikuyukikuyu_male_speakerkikuyu_female_speaker
East AfricaLugandaluganda_male_speakerluganda_female_speaker
East AfricaKinyarwandakinyarwanda_male_speakerkinyarwanda_female_speaker
East AfricaAmharicamharic_male_speakeramharic_female_speaker
East AfricaOromooromo_male_speakeroromo_female_speaker
East AfricaTigrinyatigrinya_male_speakertigrinya_female_speaker
East AfricaSomalisomali_male_speakersomali_female_speaker
East AfricaMalagasymalagasy_male_speakermalagasy_female_speaker
Southern AfricaXhosaxhosa_male_speakerxhosa_female_speaker
Southern AfricaZuluzulu_male_speakerzulu_female_speaker
Southern AfricaAfrikaansafrikaans_male_speakerafrikaans_female_speaker
Southern AfricaTswanatswana_male_speakertswana_female_speaker
Southern AfricaSesothosesotho_male_speakersesotho_female_speaker
Southern AfricaSepedisepedi_male_speakersepedi_female_speaker
Southern AfricaVendavenda_male_speakervenda_female_speaker
Southern AfricaSwatiswati_male_speakerswati_female_speaker
Southern AfricaShonashona_male_speakershona_female_speaker
Southern AfricaChichewachichewa_male_speakerchichewa_female_speaker
Southern AfricaTsongatsonga_male_speakertsonga_female_speaker
Southern AfricaNdebelendebele_male_speakerndebele_female_speaker
Southern AfricaBembabemba_male_speakerbemba_female_speaker
Southern AfricaUmbunduumbundu_male_speakerumbundu_female_speaker
Central AfricaLingalalingala_male_speakerlingala_female_speaker
North AfricaArabicarabic_male_speakerarabic_female_speaker
North AfricaBerberberber_male_speakerberber_female_speaker

Supported Languages

You can send either the full English name (e.g. Swahili) or the lowercase slug (swahili). Common aliases (e.g. kiswahili, fulani) are also accepted.

LanguageSlugLanguageSlug
AfrikaansafrikaansAmharicamharic
ArabicarabicBambarabambara
BembabembaBerberberber
ChichewachichewaEnglishenglish
EweeweFonfon
FulafulaHausahausa
IgboigboKanurikanuri
KikuyukikuyuKinyarwandakinyarwanda
KriokrioLingalalingala
LugandalugandaMalagasymalagasy
NdebelendebeleOromooromo
SepedisepediSesothosesotho
ShonashonaSomalisomali
SwahiliswahiliSwatiswati
TigrinyatigrinyaTsongatsonga
TswanatswanaTwitwi
UmbunduumbunduVendavenda
WolofwolofXhosaxhosa
YorubayorubaZuluzulu

Errors & HTTP Status Codes

When an error occurs prior to audio generation, responses use the standardized Mansa JSON error format (HttpErrorDto):

{
  "type": "about:blank",
  "title": "VALIDATION_ERROR",
  "isError": true,
  "detail": "Text exceeds the maximum allowed length of 8000 characters",
  "invalidParams": [],
  "context": ""
}
HTTP StatusError Category (title)Common Causes
400BAD_REQUESTMalformed request body.
401AUTHENTICATION_ERRORMissing or invalid API key.
402PAYMENT_ERRORInsufficient credit balance to synthesize speech.
422VALIDATION_ERRORText length exceeds 8,000 characters, or missing language / text.
500SERVER_ERRORUpstream model synthesis failure.

Billing & Credits

  • Rate: Speech synthesis is billed based on input text character length at $0.10 per 1K characters ($100 per 1M characters).
  • Solvency Check: A preflight check ensures your account has sufficient credits before synthesis begins.
  • Stream Settlement: If a progressive streaming connection is severed mid-stream by the client, credits are charged only for the audio bytes transmitted prior to disconnection.

For volume packages and credit purchases, see Pricing.