This is a Flask-based API that translates input text using a pre-trained TensorFlow model. The API accepts POST requests with input text and returns the translated output.
Translates english and swahili phrases to sukuma tribe language
-
Clone the repository:
git clone https://github.com/masakachristopher/translator-flask-server.git
-
Change directory to the root folder of your project:
cd translator-flask-server
-
Create virtual environment
python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Download the resorces here
sukuma-translation
andtokens
folders -
Create folder with name
models
in the project root folder and place thesukuma-translation
folder inside it. If named otherwise, such astrans
please rename it tosukuma-translation
- Root - models - sukuma-translation - src - app // others root files or folders
-
Place folder with name
tokens
in the project root folder which contains the tokenizer files inside it- Root - tokens - input_tokenizer.pkl - target_tokenizer.pkl - src - app // others root files or folders
-
Run your app
flask run
-
Make request
-
Headers:
Content-Type: application/json
-
Body (Json Payload)
{ "text": "water" }
or
{ "text": "hapana" }
-
Response sample
{ "translated_text": "minze" }
-
Customize the model and translations:
- If you want to use a different pre-trained TensorFlow model, replace the trans file with your own trained model. Update the file path in the Flask app accordingly.
- If you want to modify the translations, update the target_texts_combined in the Flask app with your desired translations
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.