New Tool Radar

Local AI

How to Transcribe an Audio File with LocalAI and Whisper

Set up a Whisper model in LocalAI, send an audio file to the /v1/audio/transcriptions endpoint, and read the transcript text back.

Schematic diagram with three steps: set up the whisper-1 model with the whisper backend, send an audio file to the /v1/audio/transcriptions endpoint, then read the transcript text back.

LocalAI can turn a recording into written text with an audio-to-text model running on your own machine. Audio to text models are models that can generate text from an audio file, and the transcription endpoint converts audio files to text. This guide uses Whisper, the default backend, and sends one audio file to the endpoint with curl. It is the opposite direction from text-to-speech: here sound goes in and words come out.

Set up the Whisper model

The transcription endpoint supports several backends: whisper.cpp, a C++ library for audio transcription, is the default; the others are moonshine, faster-whisper, WhisperX, parakeet-cpp, llama-cpp, voxtral, NeMo-Speech.cpp, and audio.cpp. The endpoint input supports all the audio formats supported by ffmpeg, and LocalAI runs the ffmpeg program from PATH, or the program that LOCALAI_FFMPEG_PATH names.

Download a Whisper model into the models folder and create a YAML file for it:

name: whisper-1
backend: whisper
parameters:
  model: whisper-en

Once LocalAI is started and the Whisper model is installed, you can use the /v1/audio/transcriptions endpoint.

Send the audio file to the transcriptions endpoint

Send the file as a multipart upload with the model name:

curl http://localhost:8080/v1/audio/transcriptions -H "Content-Type: multipart/form-data" -F file="@<FILE_PATH>" -F model="<MODEL_NAME>"

The docs give a worked example with a real recording: download the example file, then send it to the endpoint with the whisper-1 model:

wget --quiet --show-progress -O gb1.ogg https://upload.wikimedia.org/wikipedia/commons/1/1f/George_W_Bush_Columbia_FINAL.ogg
curl http://localhost:8080/v1/audio/transcriptions -H "Content-Type: multipart/form-data" -F file="@$PWD/gb1.ogg" -F model="whisper-1"

Read the transcript back

The reply is JSON with a text field holding the whole transcript. For the docs’ example file, the text begins “My fellow Americans, this day has brought terrible news and great sadness to our country.” and the reply also carries segments with start and end times for each part of the speech.

You can ask for a different shape with the response_format field: one of json (the default), verbose_json, text, srt, vtt, or lrc. The verbose_json reply includes text, language, duration, and segments[]. With subtitles, the docs’ example starts like this:

curl http://localhost:8080/v1/audio/transcriptions -H "Content-Type: multipart/form-data" -F file="@$PWD/gb1.ogg" -F model="whisper-1" -F response_format="srt"
1
00:00:00,000 --> 00:00:09,640
My fellow Americans, this day has brought terrible news and great sadness to our country.

Two more fields are worth knowing: language is an ISO-639-1 language hint such as en, passed through to the backend, and prompt is an optional context hint to bias the decoder. With stream set to true, the endpoint emits an SSE stream of transcript text events instead of one reply at the end.

Try it: four checks from model to transcript

Check What you should see If you do not see it
Model set up A whisper-1 model configured with backend: whisper Check the YAML file name and backend, and that LocalAI has started with the model installed
Request sent A reply from /v1/audio/transcriptions with no error Check the file path after @, the model name, and that LocalAI is running on localhost:8080
Text returned A text field with the words spoken in the recording Check the model name matches the installed model and the audio file is one ffmpeg supports
Subtitles format With response_format=srt, numbered lines with start and end times; for the docs’ example file the first line runs 00:00:00,000 --> 00:00:09,640 Check the response_format field is spelled srt and the request used the same file and model

Expected result. We checked the LocalAI audio to text docs page, which gives the whisper.cpp default backend and the other backends, the ffmpeg input formats and LOCALAI_FFMPEG_PATH, the whisper-1 YAML with backend whisper and model whisper-en, the /v1/audio/transcriptions curl command with the file and model fields, the gb1.ogg example download and request, the reply text beginning “My fellow Americans, this day has brought terrible news and great sadness to our country.”, the response_format choices json, verbose_json, text, srt, vtt, and lrc with the srt example starting 00:00:00,000 –> 00:00:09,640, the verbose_json fields text, language, duration, and segments[], the language and prompt fields, and streaming with stream set to true. We did not install LocalAI, download any audio file, or transcribe anything on this machine.

Limits

This guide covers one flat transcript from one audio file only. It does not tell you who spoke when: for that, the docs point to speaker diarization, where /v1/audio/diarization returns time-stamped speaker segments. WhisperX diarization needs an HF_TOKEN, and the docs say requests fail when it is missing. A transcript is the model’s best hearing of the recording, not a certified record — names and numbers in it still need checking against the audio. We did not run any of this ourselves.

Sources

See all