New Tool Radar

Local AI

How to Set the Language for a whisper.cpp Transcription

Pass -l with a language code to whisper-cli so a transcription runs in the language you choose instead of the default English or auto-detect.

Schematic diagram with three steps: pick a language code and a multilingual model, run whisper-cli with -l, and check the log line shows the language you set.

whisper.cpp assumes English when you do not tell it otherwise — the help page gives the language flag a default of en — so a non-English recording gets transcribed as if it were English, which garbles the whole transcript. The fix is to set the language yourself with the -l flag. The project’s own help page defines it as -l LANG, --language LANG, spoken language, with 'auto' for auto-detect, and a default of en. This guide is about whisper.cpp’s own language flag; it is different from the openai-whisper language guide, which sets --language on the Python whisper command, a different tool.

Pick a language code and a matching model

Pick the code for the language actually spoken — de for German, es for Spanish, fr for French. The README’s Quick start downloads base.en and runs it on the English jfk.wav sample, so for a non-English recording, download a multilingual model instead — small is one of the models the README lists. Build the project first if you have not already, with the README’s own commands:

git clone https://github.com/ggml-org/whisper.cpp.git
cd whisper.cpp
cmake -B build
cmake --build build -j --config Release

Then download the model:

sh ./models/download-ggml-model.sh small

That gives you models/ggml-small.bin. Convert your recording to 16-bit WAV first if it is not already one — the README’s example uses ffmpeg for that:

ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav

Run whisper-cli with -l

Pass the language code with -l. For a German recording, the command is:

./build/bin/whisper-cli -m ./models/ggml-small.bin -f talk.wav -l de

For a practice check, use a short recording in a language you can read, and listen to the first minute yourself before you look at the transcript, so you know what the words should be.

Check the log line, and try auto-detect

The README’s own log line for a transcription run shows the language the run used:

main: processing './samples/jfk.wav' (176000 samples, 11.0 sec), 4 threads, 1 processors, lang = en, task = transcribe, timestamps = 1 ...

On your run, that line should show lang = de for the German example above. Read the transcript next: the words should be in the language you set, with no English words mixed in where the speaker did not switch languages. To compare with auto-detect, run the same file once with -l auto and once with -dl: the help page defines -dl, --detect-language as exiting after automatically detecting the language, so the -dl run prints the detected language and stops without a transcript. If auto-detect names the wrong language on your clip, that is the case for setting -l yourself.

Try it: four checks

Check What you should see If you do not see it
Model A file called models/ggml-small.bin after the download script Download a multilingual model such as small — the Quick start’s base.en is the model the README uses for its English sample
Flag The command includes -l de Without -l the default is en, so a non-English recording is transcribed as if it were English
Log The log line shows lang = de, task = transcribe Check the -l value matches the language actually spoken in the recording
Detect A run with -dl prints the detected language and exits without a transcript Use -l auto to compare auto-detect with the language you set

Expected result. We checked the whisper.cpp README for the Quick start build and download commands, the 16-bit WAV conversion with ffmpeg, the 11.0-second jfk.wav log line with its lang and task fields, and the list of downloadable models including small; and the whisper-cli help page for the -l LANG, –language LANG flag with ‘auto’ for auto-detect and its en default, the -dl –detect-language flag that exits after automatically detecting the language, the -m model path, and the -f file path. We did not run whisper.cpp or transcribe any audio.

Limits

Setting the language only tells the model which language to expect — it does not fix a recording the model cannot hear clearly, and a wrong code is worse than auto-detect, because the model will then force the wrong language onto the audio. The language code has to match the language actually spoken; if a recording switches languages halfway through, one code cannot cover both parts. This is whisper.cpp’s own language flag, which is different from the openai-whisper language guide and from plain transcription without the flag. We did not run whisper.cpp, so no transcript here is a recorded result.

Sources

See all