Logo Lanfrica

ogayanfe/hausa-tts-server

Domaine:

natural language processing

Type de record:

softwaretools
Créateur:
oga
HĂ´te:
Takes in Hausa text and returns a Hausa audio .wav file # 🗣️ Gani Hausa TTS Backend (Flask) This backend provides a **Text-to-Speech (TTS)** API for generating **Hausa audio** responses using the **CLEAR-Global Hausa TTS model**. It powers the Gani AI assistant by converting Hausa text into high-quality spoken audio. --- ## 🚀 Features - Converts Hausa text to natural speech. - Uses **Hugging Face CLEAR-Global Hausa TTS model**. - Returns audio in `.wav` format. - Simple REST API endpoint: `/api/tts`. --- ## ⚙️ Setup Instructions ### 1. Clone the Repository ```bash git clone github.com cd hausa-tts-backend ``` ### 2. Create and Activate a Virtual Environment ```bash python -m venv venv # Activate it: # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate ``` ### 3. Install Dependencies ```bash pip install -r requirements.txt ``` ### 4. Create a `.env` File In the project root, create a `.env` file and add the following: ```bash FLASK_ENV=development FLASK_APP=app.py SECRET_KEY="YOUR FLASK SECRET" ``` (Optional) Add your Hugging Face token if needed: ```bash HUGGINGFACE_HUB_TOKEN=your_hf_token_here ``` --- ## 🧩 Project Structure ``` app/ ├── __init__.py ├── routes.py # Defines the /api/tts route config.py model.py # Loads and runs the Hausa TTS model requirements.txt app.py # Entry point for Flask app ``` --- ## ▶️ Running the Server Locally ### Option 1: Using Flask’s built-in server ```bash flask run ``` ### Option 2: Using Python directly ```bash python app.py ``` You should see: ``` * Running on 127.0.0.1 ``` --- ## 🔉 API Endpoint ### `POST /api/tts` **Description:** Converts Hausa text to audio and returns a `.wav` file. **Request Body:** ```json { "text": "Ina kwana?" } ``` **Response:** - Returns binary WAV audio data. - You can play it directly or convert it to Base64 in your frontend. **Example using cURL:** ```bash curl -X POST 127.0.0.1 \ -H "Content …