This is a simple transcriber API that uses whisper to transcribe audio files.
download model you should download the model from here and put it in the models folder.
ex: data/models/ggml-base.bin and data/models/ggml-small.bin and data/models/ggml-medium.bin.
after you have modified the .laure file
laure create && laure push && laure runENV LAURE_HOST="0.0.0.0"
ENV LAURE_PORT="5000"docker build -t testing-stt .docker run -d -p 5000:5000 --name stt testing-sttdocker rm -f stt| Method | Endpoint | Description |
|---|---|---|
| GET | / | Welcome message |
| POST | /transcribe | Transcribe an audio file |
| GET | /transcribe | Get the transcription of the audio file |
Welcome message
{
"success": "Welcome to the Whisper API"
}| Parameter | Type | Description |
|---|---|---|
| success | string | The welcome message |
Transcribe an audio file to text and return the id of the transcription
application/octet-stream is the only accepted content type for the file, use stream=True with requests.post to send the file if you are using requests in python
| Parameter | Type | Description | Additional Info |
|---|---|---|---|
| model | string | The model to use for the transcription | optional, default is base and you can use base/small/medium |
| file | file | The audio file to transcribe | |
| secret | string | Secret key to use the API | actually not used |
| Parameter | Type | Description | Additional Info |
|---|---|---|---|
| id | string | The id of the transcription | |
| success | boolean | True if the transcription was successful | only if success |
| error | string | The error message if the transcription failed | only if not success |
Get the transcription of the audio file
| Parameter | Type | Description | Additional Info |
|---|---|---|---|
| id | string | The id of the transcription |
| Parameter | Type | Description | Additional Info |
|---|---|---|---|
| text | string | The transcription of the audio file | |
| status | string | The status of the transcription | success/running/failed |
| success | string | Success is present if the transcription succeeded or is running | only if not failed |
| error | string | The error message if the transcription failed | only if failed |
with open(file_path, "rb") as audio_file:
files = {"file": audio_file}
response = requests.post(url=url, data={
"model": model
}, files=files, verify=False, stream=True)
result = response.json()
print(result){
"id": "5f7e3b3e-3b3e-4e3b-7e3f-3b3e4e3b7e3f",
"success": true
}result = get_text(url, id)
if "error" in result:
result = {"status": "failed", "text": result["error"]}
elif result["status"] == "success":
result = {"status": "success", "text": result["text"]}
else:
result = {"status": "running"}
print(result){
"text": "The transcription of the audio file",
"status": "success",
"success": true
}- Add a way to change the model
- Add a way to change the language
- maybe a ffmpeg to convert the audio file to the right format
- Add a way to get json output
- Add option like temperature, initial_prompt, ...