Transcribe your own sentence on a laptop

Turn an 11-second recording into text with Whisper, time it, then try a sentence of your own.

Guided walkthrough·Beginner·3 min read

Recognize a spoken digit

Listen and guess the digit, then compare your answer with a model trained on the English words zero through nine.

Try your own recording

The 6.3 KiB classifier identified 282 of 300 held-out recordings from the same six speakers. Try clip 3 to hear one it missed. Recordings, model and license

Requirements and learning goals

Before you start

  • macOS or Linux with Git, CMake, a C/C++ compiler and build tools
  • Internet access for the initial download
  • Optional for your own clip: an audio recorder and FFmpeg

You will be able to

  • Save a transcript produced on your CPU
  • Compare the processing time with the length of the recording
  • Check whether speech recognition preserves a spoken quantity

Can your laptop transcribe a recording faster than it plays? Start with a short clip of John F. Kennedy supplied with whisper.cpp. Once you have the code and the English model, the exercise works offline. Your audio stays on your computer.

1. Build the transcriber

Run these commands in a terminal. They download whisper.cpp v1.8.2, build its command-line transcriber, and fetch the English model, about 75 MiB. Keep the terminal in the whisper.cpp directory.

git clone --branch v1.8.2 --depth 1 https://github.com/ggml-org/whisper.cpp.git
cd whisper.cpp
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_METAL=OFF
cmake --build build --config Release --target whisper-cli -j 4
sh models/download-ggml-model.sh tiny.en

2. Listen, then run the model

Open samples/jfk.wav in your audio player. Listen for the two halves of the sentence and where the word “not” appears. Then run:

/usr/bin/time -p ./build/bin/whisper-cli -m models/ggml-tiny.en.bin \
  -f samples/jfk.wav -l en -t 4 -ng -otxt -of jfk
cat jfk.txt

The command uses four CPU threads. It writes the words to jfk.txt and prints timestamps in the terminal. Look for the line beginning with real just before the file contents. That's the elapsed time in seconds, including loading the model.

Expected result

The clip lasts 11 seconds. The transcript should include “ask not what your country can do for you” followed by “ask what you can do for your country.” A missing “not” changes the meaning even if the rest of the sentence is correct.

On an Apple M4 Max this command took 0.29 seconds, about 38 times faster than playback. Divide 11 by your own real time. A value above one means your computer finished before the recording would have ended.

3. Try a sentence of your own

Record yourself saying “There are three blue cups on the workbench.” Put the recording in the project directory. Replace my-recording.m4a with its filename. These commands convert it to mono, 16 kHz audio and save a second transcript:

ffmpeg -i my-recording.m4a -ar 16000 -ac 1 -c:a pcm_s16le workbench.wav
./build/bin/whisper-cli -m models/ggml-tiny.en.bin \
  -f workbench.wav -l en -t 4 -ng -otxt -of workbench
cat workbench.txt

Check the quantity, color, and object against your recording. Both “3 blue cups” and “three blue cups” preserve what you said. Try recording “two blue cups” and listen again if the number in the transcript differs.

Troubleshooting

If the model fails to load, check that models/ggml-tiny.en.bin exists in this directory. An interrupted download can leave a partial file. Compare its SHA-1 with the tagged model list, move the partial file aside, and rerun the download command. If the JFK clip works but your own transcript is empty, play workbench.wav and check that you can hear the words.

Can you do each of these?

  • Save a transcript produced on your CPU
  • Compare the processing time with the length of the recording
  • Check whether speech recognition preserves a spoken quantity
Previous: Recognize a spoken digit on your board
All lessons in this topic
  1. 1. Install WendyOS on your board
  2. 2. Recognize a spoken digit on your board
  3. 3. Transcribe your own sentence on a laptop
  4. 4. Find objects in a photo with YOLO

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.