A Python library for interacting with the GhanaNLP APIs
Project description
Ghana NLP Python Library
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.
Features
- 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.
Installation
You can install the library directly from PyPI:
pip install ghana-nlp
And update to the lastest version
python -m pip install --upgrade ghana-nlp
Usage
Initialize the Library
First, import the library and set your API key:
from ghana_nlp import GhanaNLP
nlp = GhanaNLP(api_key="your_api_key_here")
Translation
Translate from English to Twi:
result = nlp.translate("Hello, how are you?", language_pair="en-tw")
print(result) # Wo ho te sɛn?
Speech-to-Text (STT)
Convert an audio file (WAV format) to text:
result = nlp.speech_to_text("your_audio_file.wav", language="tw")
print(result)
Text-to-Speech (TTS)
Convert text to speech:
result = nlp.text_to_speech("Good morning", lang="tw")
print(result) # audio binary, write a code to either serve to an audio file or play directly
Check this repo to guide you with dealing with audio binary data: EXAMPLE CODE
Supported Languages
The library supports multiple African languages, including:
- English (en)
- Twi (tw)
- Ga (gaa)
- Ewe (ee)
- Fante (fat)
- Dagbani (dag), and more!
Error Handling
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.
License
This library is licensed under the MIT License.
For more details, check out the documentation and start building cool stuff with Ghana NLP! 🎉
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ghana-nlp-0.1.5.tar.gz
.
File metadata
- Download URL: ghana-nlp-0.1.5.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d723a9b7ba7996c46b32e123e911ed5dbe0e45fba7f410dad6c920cfcf4ed2bf |
|
MD5 | 6cc68fae97676cba685676873094c58a |
|
BLAKE2b-256 | 7c8a70e93384008e132277e82b68262520dce9e2148be5fde240617bf743fd80 |
File details
Details for the file ghana_nlp-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: ghana_nlp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ae8d813a7a1f8603f01bb41f2fd07a9bf2ea1dcadfedf77d472fb0c4067981 |
|
MD5 | b7c46699fc42c6c2445991028d3b5bfd |
|
BLAKE2b-256 | 200e37bc6a0bc897b7a6f1bc583589b9f2ee0bc6b90a63d18551ab2f19de2591 |