This project provides a robust, high-performance API for generating subtitles (.srt compatible content) from audio files using an optimized version of OpenAI's Whisper model. It is built with Flask and packaged in a Docker container for easy deployment and scaling.
The API leverages insanely-fast-whisper to deliver significantly faster transcription speeds compared to the original implementation, making it suitable for production workloads.
Once the image is successfully built, you can run it as a container:
docker run -p 5000:5000 dattm24/whisper-srt-api:1.0
This command starts the container and maps port 5000 of the container to port 5000 on your host machine. You should see output from Flask and the model loading process, ending with a line indicating the server is running. The API is now accessible at http://localhost:5000.
You can interact with the API using any HTTP client, such as curl or Postman.
This endpoint is for quick, blocking transcription requests. You send an audio file and receive the SRT text in the response body.
/transcribePOSTmultipart/form-data
audio: The audio file to transcribe (e.g., .mp3, .wav, .m4a). (Required)language: The two-letter language code (e.g., es, fr, de). Defaults to en. (Optional)Example (English):
curl -X POST -F "audio=@/path/to/your/audio.mp3" http://localhost:5000/transcribe
Example (Spanish):
curl -X POST \
-F "audio=@/path/to/your/audio.mp3" \
-F "language=es" \
http://localhost:5000/transcribe
Success Response:
200 OKThis endpoint is ideal for long audio files. It accepts the file, starts a background transcription process, and immediately returns a unique task_id.
/tasksPOSTmultipart/form-data
audio: The audio file to transcribe. (Required)language: The two-letter language code. Defaults to en. (Optional)Example:
curl -X POST \
-F "audio=@/path/to/a/long_podcast.mp3" \
-F "language=en" \
http://localhost:5000/tasks
Success Response:
200 OK{
"task_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
}
Use this endpoint to check the status of an asynchronous job and get the result when it's ready.
/tasks/<task_id>GETExample:
# Use the task_id from the previous step
curl http://localhost:5000/tasks/a1b2c3d4-e5f6-7890-1234-567890abcdef
Responses:
200 OK{
"status": "processing"
}
200 OK<task_id>.srt containing the subtitle data.500 Internal Server Error{
"status": "failed",
"message": "Transcription failed."
}
404 Not Found{
"error": "Task not found"
}
Content type
Image
Digest
sha256:0946592bf…
Size
3.4 GB
Last updated
over 1 year ago
docker pull dattm24/whisper-srt-api:1.0