馃 distributed transcription service thistle.dunkirk.sh
1# Whisper Transcription Server 2 3This is a FastAPI server that provides real-time audio transcription using the faster-whisper library. 4 5## Features 6 7- Real-time transcription with streaming progress updates 8- Supports multiple audio formats (MP3, WAV, M4A, etc.) 9- Language detection 10- Segment-based transcription with timestamps 11- RESTful API endpoint 12 13## Setup 14 15### 1. Install Dependencies 16 17```bash 18pip install -r requirements.txt 19``` 20 21### 2. Run the Server 22 23**Option 1: Manual setup** 24```bash 25pip install -r requirements.txt 26python main.py 27``` 28 29**Option 2: Quick start script** 30```bash 31./run.sh 32``` 33 34The server will start on `http://localhost:8000` and load the Whisper model (this may take a few minutes on first run). 35 36## API Usage 37 38### POST `/transcribe-with-progress` 39 40Upload an audio file to get real-time transcription progress. 41 42**Example with curl:** 43```bash 44curl -X POST "http://localhost:8000/transcribe-with-progress" \ 45 -F "file=@/path/to/your/audio.mp3" 46``` 47 48**Streaming Response:** 49The endpoint returns a stream of JSON objects: 50 51```json 52{"status": "starting", "total_duration": 15.36, "language": "en", "language_probability": 0.99} 53{"status": "progress", "percentage": 25.59, "start": 0.0, "end": 3.93, "text": "This is a test of the transcription server."} 54{"status": "progress", "percentage": 57.68, "start": 3.93, "end": 8.86, "text": "It should be streaming the results back in real time."} 55{"status": "complete"} 56``` 57 58### Response Format 59 60- `starting`: Initial metadata about the audio file 61- `progress`: Transcription segments with progress percentage 62- `complete`: Transcription finished successfully 63- `error`: An error occurred during transcription 64 65## Configuration 66 67You can modify the model settings in `main.py`: 68 69```python 70model_size = "base" # Options: tiny, base, small, medium, large-v1, large-v2, large-v3 71model = WhisperModel(model_size, device="cpu", compute_type="int8") 72``` 73 74For GPU acceleration, change to: 75```python 76model = WhisperModel(model_size, device="cuda", compute_type="float16") 77``` 78 79## Integration with Thistle 80 81This server is designed to work with the Thistle web application. Set the `WHISPER_SERVICE_URL` environment variable in Thistle to point to this server. 82 83```bash 84# In Thistle's .env file 85WHISPER_SERVICE_URL=http://localhost:8000 86```