muzammil-rehman-iub-edu-pk/bidirectional-sign-speech-translator
0
Sign Speech Backend
This FastAPI backend powers the app's mobile-only features:
- Speech-to-text for Teacher mode
- Gesture recognition for Student mode
The Expo app calls this service using EXPO_PUBLIC_MOBILE_API_URL.
Local Development
Prerequisites
- Python 3.11+
- Homebrew
ffmpegfor speech-to-text
Install ffmpeg:
brew install ffmpegSetup
cd backend
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip setuptools wheel
pip install -r requirements.txtRun Locally
python -m uvicorn main:app --host 0.0.0.0 --port 8000Health checks:
http://localhost:8000/http://localhost:8000/health
App Configuration
Set EXPO_PUBLIC_MOBILE_API_URL in the Expo app .env file.
Common values:
- iOS Simulator:
http://localhost:8000 - Android Emulator:
http://10.0.2.2:8000 - Physical device:
http://<YOUR_MAC_LAN_IP>:8000
Hugging Face Spaces
This folder is ready to deploy as a Docker Space.
What To Upload
Create a new Hugging Face Space with SDK set to Docker, then push the contents of this backend/ folder to that Space repository root.
Required files already included here:
README.mdDockerfilerequirements.txtmain.py
One-Command Push Helper
From the project root, you can push backend/ to your Space repo with:
./deploy-backend-to-hf.sh https://huggingface.co/spaces/<username>/<space-name>If your Space uses a branch other than main, pass it as the second argument:
./deploy-backend-to-hf.sh https://huggingface.co/spaces/<username>/<space-name> mainSpace Variables
Add these runtime variables in the Space Settings:
WHISPER_MODEL=tinyWHISPER_DEVICE=cpuWHISPER_COMPUTE_TYPE=int8
Optional:
HF_TOKENif you want higher download limits for model pulls.
Expected Public URL
After deploy, Hugging Face gives you a URL like:
https://<your-space-name>.hf.spaceUse that URL in the app:
EXPO_PUBLIC_MOBILE_API_URL=https://<your-space-name>.hf.spaceEndpoints
GET /GET /healthPOST /gesturePOST /stt
Notes
- The first
/sttrequest can be slow because Whisper may download the model on first use. - Free CPU Spaces can sleep after inactivity and may cold start on the next request.
tinyis the safest Whisper model for a free CPU deployment.
