This API application allows users to upload audio files and convert them into text using Vosk, a speech recognition library.
- Upload audio files in various formats (MP3, WAV, etc.)
- Convert audio to text using the Vosk model
- Supports authentication through headers
Before getting started, ensure you have the following:
- Docker: Make sure Docker and Docker Compose are installed on your system. Follow the installation guide for Docker here.
- FFmpeg: Ensure FFmpeg is installed for converting audio formats. If using Docker, FFmpeg is already included in the image used.
- .env File: Copy .env.example to .env and input your backend API_KEY. This API_KEY is used to restrict access to the application, ensuring that it can only be accessed from authorized servers (You can use custom generated API key or random text).
git clone https://github.com/dammar01/api-voice-to-text.git
cd api-voice-to-textpython -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`pip install -r requirements.txtuvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadusing postman or
curl -X POST http://0.0.0.0:8000 \
-H "Authorization: Bearer API_KEY" \
-F "file=@path_to_your_audio_file"docker pull dmmrs/api-voice-to-text:latestdocker run -d -p 8000:8000 -e API_KEY=YOUR_API_KEY dmmrs/api-voice-to-text:latestusing Postman or cURL
curl -X POST http://localhost:8000 \
-H "Authorization: Bearer API_KEY" \
-F "file=@path_to_your_audio_file"To replace the default Vosk model with your custom model, follow these steps:
Visit the Vosk model repository and choose the model that fits your needs. Download and extract the model files.
After extracting the model files, you will have a folder named after the model, e.g., vosk-model-en-us-daanzu-20200905. Rename this folder to vosk to match the expected folder name in the application.
Replace the existing vosk model folder inside your application directory at ./app/vosk. You can do this manually by copying the newly downloaded vosk folder into the directory:
cp -r /path_to_downloaded_model/vosk ./app/voskThis will overwrite the old model files with your new model.