Logo Lanfrica

dickson08/Deploy-Hausa-Automatic-Speech-Recognition-to-modal

Domaine:

natural language processing

Type de record:

software
Créateur:
dic
Hôte:
# **Hausa Speech to Text API, Modal Deployment** This repository contains a fully containerized Hausa speech to text API built with FastAPI, Transformers, and Modal. It exposes a simple `/transcribe` endpoint that accepts audio files and returns Hausa transcripts with latency metrics. --- ## **Features** * Containerized ASR service running on Modal * Uses the Hausa model `CLEAR-Global/w2v-bert-2.0-hausa_100_400h_yourtts` * Automatic CUDA detection and mixed precision optimizations * Handles short and long audio through chunked transcription * Overlap logic prevents cutting words during chunk boundaries * FastAPI interface for easy integration * GPU optimized with A100 support * Model loads once per container and stays warm for 5 minutes --- ## **Architecture** **Modal Functions** * `transcribe()` Runs on GPU. Loads and caches the Hausa ASR pipeline. Handles: * audio decoding with ffmpeg * chunked inference * CUDA memory cleanup * latency measurement * `api()` ASGI entrypoint that exposes FastAPI as a public HTTP service. **Flow** ``` Client --> /transcribe --> FastAPI --> Modal GPU Function --> Transformer ASR --> Response(JSON) ``` --- ## **Endpoints** ### `POST /transcribe` Accepts multipart form data. **Body** ``` file: audio/wav or audio/mp3 ``` **Response** ```json { "text": "transcribed hausa...", "latency_sec": 0.63 } ``` --- ## **How to Deploy on Modal** 1. Install Modal locally: ```bash pip install modal ``` 2. Log in: ```bash modal token new ``` 3. Deploy the service: ```bash modal deploy app.py ``` 4. Or run locally for testing: ```bash modal run app.py ``` --- ## **Calling the API** ### Example with `curl` ```bash curl -X POST \ -F "file=@sample.wav" \ your-modal-url ``` ### Example with Python ```python import requests url = "your-modal-url" files = {"file": open("sample.wav", "rb")} res = requests.post(url, files=files) print(res.json()) ``` --- ## **Model and Audio Handling* …

Languages