Also known as text-to-speech (TTS), speech generation/synthesis is integral part to modern AI systems. We have built this endpoint with strong support for African languages.

Request

The generate() function can be used to generate speech. Examples are provided below as a guide for you.

Best Practices for Use

  • We highly recommend that you perform tone-marking first before TTS. This allows the model to pronounce the words properly during speech generation.
  • Make sure your text has correct punctuation before sending it for speech generation to achieve more natural and accurate output.
  • Not all voices work for all languages. Ensure you select the voice that matches the language of your choice. More info on voices can be found on the Voices page

Response

The response for speech generation is in bytes.
  • The Content-Type is audio/wav
  • The content is streamed back to the caller.
  • The file type of the generated audio is wav. If you use the streaming interface (Python SDK), you can start to take action on the byte chunks, e.g. stream to file.

Choosing a Voice

We currently have 8 characters with unique voices for the supported languages. Each of these characters has unique attributes, we think you will find them fun to use. Feel free to try them out and let us know which one you love the most. 😉

Language Support

The speech generation model supports the following languages:
  • English: en
  • Hausa: ha
  • Igbo: ig
  • Amharic: am
  • Yoruba: yo

Examples

Python
import os
from spitch import Spitch

os.environ["SPITCH_API_KEY"] = "YOUR_API_KEY"
client = Spitch()

with open("new.mp3", "wb") as f:
    response = client.speech.generate(
        text="Bawo ni ololufe mi?",
        language="yo",
        voice="sade"
    )
    f.write(response.read())

Examples - streaming

Python
import os
from spitch import Spitch

os.environ["SPITCH_API_KEY"] = "YOUR_API_KEY"
client = Spitch()

with client.speech.with_streaming_response.generate(
    text="Bawo ni ololufe mi?",
    language="yo",
    voice="funmi"
) as response:
    response.stream_to_file("new.wav")