Multimodal AI server for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
Project description
Dhwani Server
Dhwani API is a FastAPI-based application providing AI-powered services for Indian languages, including text-to-speech (TTS), language model (LLM) chat, vision-language model (VLM) capabilities, and automatic speech recognition (ASR). It supports lazy loading of models for fast startup and includes endpoints for various tasks.
Features
- Text-to-Speech (TTS): Generate audio from text in Indian languages using Parler TTS.
- Chat: Process Kannada prompts and respond in Kannada via translation and LLM.
- Vision-Language Model (VLM): Caption images, answer visual queries, detect, and point objects.
- Automatic Speech Recognition (ASR): Transcribe audio files in multiple Indian languages.
- Lazy Loading: Models load on-demand or via an explicit endpoint for fast startup.
Prerequisites
-
**System Requirements - User **:
- Python: 3.10
- Ubuntu 22.04
- git
- vscode
-
**System Requirements - Server **:
- Ubuntu with sufficient RAM (16GB+ recommended for models).
- Optional: NVIDIA GPU with CUDA support for faster inference.
-
FFmpeg: Required for audio processing (ASR).
-
Server Setup
export HF_HOME=/home/ubuntu/data-dhwani-models
export HF_TOKEN='YOur-HF-token'
python src/server/main.py --host 0.0.0.0 --port 7860 --config config_two
Installation
-
Clone the Repository:
git clone https://github.com/slabstech/dhwani-server cd dhwani-server
-
Install Libraries:
- On Ubuntu:
sudo apt-get install ffmpeg build-essential
- On Ubuntu:
-
Set Up Virtual Environment:
python -m venv venv source venv/bin/activate
-
Install Dependencies:
sudo apt-get install -y ffmpeg build-essential curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal . "$HOME/.cargo/env" export CC=/usr/bin/gcc export ENV CXX=/usr/bin/g++
pip install --no-cache-dir --upgrade pip setuptools psutil setuptools-rust torch==2.6.0 pip install --no-cache-dir flash-attn --no-build-isolation
pip install -r requirements.txt
-
Set Environment Variable: Create a .env file in the root directory and add your API key: plaintext
API_KEY=your_secret_key
-
Running the Server
- Start the Server:
python src/server/main.py --host 0.0.0.0 --port 7860 --config config_two
-
The server starts with models loaded on start
-
Access the interactive API docs at http://localhost:7860/docs.
-
(Optional) Load All Models: Preload all models (LLM, Translation, TTS, VLM, ASR) with:
curl -X POST "http://localhost:7860/load_all_models" -H "X-API-Key: your_secret_key"
-
Usage
-
Endpoints
- All endpoints require the X-API-Key header with the value from your .env file.
-
Health Check: GET /health
curl "http://localhost:7860/health"
-
Response:
{"status": "healthy", "model": "Qwen/Qwen2.5-3B-Instruct"}
-
Text-to-Speech: POST /v1/audio/speech
curl -X POST "http://localhost:7860/v1/audio/speech" -H "X-API-Key: your_secret_key" -H "Content-Type: application/json" -d '{"input": "ನಮಸ್ಕಾರ", "voice": "Female voice", "model": "ai4bharat/indic-parler-tts", "response_format": "mp3"}' --output speech.mp3
- Chat: POST /chat
curl -X POST "http://localhost:7860/chat" -H "X-API-Key: your_secret_key" -H "Content-Type: application/json" -d '{"prompt": "ನೀವು ಹೇಗಿದ್ದೀರಿ?"}'
- Response:
{"response": "<Kannada response>"} - Image Captioning: POST /caption/
curl -X POST "http://localhost:7860/caption/" -H "X-API-Key: your_secret_key" -F "file=@image.jpg" -F "length=short"
- Response:
{"caption": "<short caption>"} - Visual Query: POST /visual_query/
curl -X POST "http://localhost:7860/visual_query/" -H "X-API-Key: your_secret_key" -F "file=@image.jpg" -F "query=What is this?"
- Response:
{"answer": "<answer>"} - Object Detection: POST /detect/
curl -X POST "http://localhost:7860/detect/" -H "X-API-Key: your_secret_key" -F "file=@image.jpg" -F "object_type=face"
- Response:
{"objects": [<list of detected objects>]} - Object Pointing: POST /point/
curl -X POST "http://localhost:7860/point/" -H "X-API-Key: your_secret_key" -F "file=@image.jpg" -F "object_type=person"
- Response:
{"points": [<list of points>]} - Transcription: POST /transcribe/
curl -X POST "http://localhost:7860/transcribe/?language=kannada" -H "X-API-Key: your_secret_key" -F "file=@audio.wav"
- Response:
{"text": "<transcribed text>"} - Batch Transcription: POST /transcribe_batch/
curl -X POST "http://localhost:7860/transcribe_batch/?language=kannada" -H "X-API-Key: your_secret_key" -F "files=@audio1.wav" -F "files=@audio2.mp3"
- Response:
{"transcriptions": ["<text1>", "<text2>"]}
-
-
Notes
- Lazy Loading: Models load on first use or via /load_all_models. Expect a delay on the first request for each model type. Supported Languages: ASR supports multiple Indian languages (e.g., kannada, hindi, tamil); see models/asr.py for the full list. Logs: Check dhwani_api.log for detailed logs (rotated at 10MB, 5 backups). Performance: Use a GPU with flash-attn installed for faster TTS and ASR inference.
-
Troubleshooting
- Module Errors: Ensure all dependencies are installed. Re-run pip install if needed. FFmpeg Not Found: Install FFmpeg and ensure it’s in your PATH. Permission Denied: Run with sudo if accessing restricted ports (e.g., < 1024).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dwani-0.1.1.tar.gz.
File metadata
- Download URL: dwani-0.1.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8589a29465c1eba5674eb4bbdb347a75f61d3ae950a7215a89a09b7b87cb1ddf
|
|
| MD5 |
4d39ebc32aa8267d6383accdef8325ae
|
|
| BLAKE2b-256 |
c3117097dc07da16b891313c47eee037bb96ab252c2bcb426ebfdf35aecb65ca
|
File details
Details for the file dwani-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dwani-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
810a1503849057f0ed6fcbcc6dc02af71d03310f4ea7cdccaecbc6e84e7e8ac1
|
|
| MD5 |
8106e4dc14b4a674a3c2f9ccc26503d8
|
|
| BLAKE2b-256 |
7d71c1041d6c2ffaae06a620dd92af80eb980848857edf69a5a2f634de8255f0
|