The Ghana NLP API Python Library provides an easy way to integrate local African language technologies into your Python projects. Whether you're looking for translation, speech-to-text (STT), or text-to-speech (TTS), this library makes it simple and intuitive to get started.
- Translation: Translate text between supported African languages (e.g., English to Twi).
- Speech-to-Text (STT): Convert audio files into text.
- Text-to-Speech (TTS): Generate natural-sounding speech from text in local languages.
You can install the library directly from PyPI:
pip install ghana-nlpAnd update to the lastest version
python -m pip install --upgrade ghana-nlpFirst, import the library and set your API key:
from ghana_nlp import GhanaNLP
nlp = GhanaNLP(api_key="your_api_key_here")Translate from English to Twi:
result = nlp.translate("Hello, how are you?", language_pair="en-tw")
print(result) # Wo ho te sɛn?Convert an audio file (WAV format) to text:
result = nlp.stt("your_audio_file.wav", language="tw")
print(result) Convert text to speech:
result = nlp.tts("Good morning", lang="tw")
print(result) # audio binary, write a code to either serve to an audio file or play directlyCheck this repo to guide you with dealing with audio binary data: EXAMPLE CODE
The library supports multiple African languages, including:
- English (en)
- Twi (tw)
- Ga (gaa)
- Ewe (ee)
- Fante (fat)
- Dagbani (dag), and more!
The library provides clear error messages if something goes wrong, such as incorrect language codes or invalid API requests. Check the message field in the response for details.
This library is licensed under the MIT License.
For more details, check out the documentation and start building cool stuff with Ghana NLP! 🎉