Spaces:
Build error
Nigerian Text-to-Speech API This is a API service that converts text to speech with authentic Nigerian accents. The API is built with FastAPI and uses the YarnGPT text-to-speech model. Features
Convert text to Nigerian-accented speech Multiple voices and languages REST API endpoints Base64 encoded audio output Simple file-based output
API Endpoints Health Check
URL: / Method: GET Response: Information about the API status and available voices/languages
Text-to-Speech
URL: /tts Method: POST Body: json{ "text": "Your text to convert to speech", "language": "english", "voice": "idera", "speed": 1.0 }
Response: JSON object with base64-encoded audio and audio URL
Get Audio File
URL: /audio/{filename} Method: GET Response: Audio file (WAV format)
Usage Examples
cURL Example
bashcurl -X POST "https://yourdomain.com/tts"
-H "Content-Type: application/json"
-d '{"text":"Welcome to Nigeria, the giant of Africa.", "language":"english", "voice":"idera"}'
Python Example
pythonimport requests
import base64
import io
from IPython.display import Audio
response = requests.post( "https://yourdomain.com/tts", json={ "text": "Welcome to Nigeria, the giant of Africa.", "language": "english", "voice": "idera", "speed": 1.0 } )
data = response.json() audio_data = base64.b64decode(data["audio_base64"]) Audio(audio_data, rate=24000) Available Voices and Languages Voices
Female: zainab, idera, regina, chinenye, joke, remi Male: jude, tayo, umar, osagie, onye, emma
Languages
english yoruba igbo hausa
Configuration The API uses the following YarnGPT model:
Model: yarngpt/yarn-tts-demo
Deployment This API is designed to run on Hugging Face Spaces with the following configuration:
SDK: Docker Hardware: CPU (recommended: GPU for better performance)