This is a small FastAPI demo that accepts an audio upload and uses the Hugging Face Inference API to transcribe audio and translate it to English. Results are stored in database.json.
Quick start
- Install dependencies (prefer a virtualenv):
python -m pip install -r requirements.txt- Set environment variables (example):
$Env:HF_API_TOKEN = "<your-hf-token>"
# optional: choose another model
$Env:HF_MODEL = "openai/whisper-small"- Run the server:
python -m uvicorn main:app --reload --port 8000- Send a file (example with
curl):
curl -X POST "http://127.0.0.1:8000/talk" -F "file=@path\to\audio.wav"Notes
- This example uses the Hugging Face Inference API (
huggingface-hub). You need an API token (free-tier available on HF). - The code attempts to store both the original transcript and an English translation in
database.json. - For a quick demo, use
openai/whisper-smallas the default model. You can switch models by settingHF_MODEL.