1.9 KiB
1.9 KiB
Whisper Speech-to-Text API Service
Overview
This project is a local API server compatible with OpenAI's API for transcribing audio to text using the Whisper model. It's designed to run as a system service, loading the Whisper model into memory at startup and handling transcription requests via REST API.
Features
- Audio Transcription: Supports various input methods:
- Local server files
- Files accessible via URL
- Base64-encoded files
- Multipart form data
- OpenAI API Compatibility: Works with
/v1/audio/transcriptionsand/v1/modelsendpoints. - Audio Preprocessing: Converts audio to WAV, normalizes, and adds silence.
- Hardware Support: Utilizes GPU (CUDA, MPS) or CPU.
- Logging: Tracks all operations.
- Health Check: Includes a health check endpoint.
Quick Start
-
Edit the Configuration File (
config.json):- Set the path to your Whisper model (
model_path). - Configure other parameters like language (
language), chunk size (chunk_length_s), batch size (batch_size), and audio normalization settings.
{ "service_port": 5042, "model_path": "/path/to/your/whisper-model", "language": "english", "chunk_length_s": 30, "batch_size": 16, "max_new_tokens": 256, "return_timestamps": false, "norm_level": "-0.5", "compand_params": "0.3,1 -90,-90,-70,-70,-60,-20,0,0 -5 0 0.2" } - Set the path to your Whisper model (
-
Run the Server:
- Simply execute the
server.shscript:
./server.sh- If you need to update the environment, use:
./server.sh --update - Simply execute the
-
Use the API:
- Once the server is running, you can send transcription requests.
- Example request (curl):
curl -X POST -F file=@audio.wav http://localhost:5042/v1/audio/transcriptions
Enjoy seamless audio-to-text transcription with your local Whisper API server!