liveBook · Manning

Speech recognition

As explained in Build Applications with Local AI Models on a Mac

The conversion of spoken audio into written text.

Speech recognition, also called automatic speech recognition (ASR), turns spoken audio into written text. It lets you speak into a microphone and use the resulting words as input to a chat application. The task is harder than it sounds: accents, speaking pace, background noise, and words that run together can all make speech ambiguous. section 9.1 section 1.2

Whisper is a speech-recognition model that can run offline. It converts audio into a spectrogram, a representation of sound frequencies over time. An encoder processes that representation; a decoder uses its output, along with tokens specifying the language and task, to generate a transcript. MLX Whisper adapts Whisper for Apple silicon so transcription can stay on your Mac. section 9.1 section 9.11

Figure 9.1 Whisper’s encoder-decoder architecture. Audio is converted into a spectrogram, which the encoder processes. The decoder processes the encoder’s output together with control tokens to generate a transcript.

Follow the diagram from audio to spectrogram, then through the encoder and decoder to the transcript. section 9.1

Turn a recording into chat input

Record with a microphone, then give MLX Whisper a file path: `result = mlx_whisper.transcribe(path, path_or_hf_repo=model)`. The recognized words are in `result["text"]`; those words can be sent to an Ollama language model just like typed input. Microphone recordings prepared for Whisper must be mono and 16 kHz. If a browser supplies in-memory WAV bytes, save them to a temporary file for transcription and delete that file in a `finally` block. section 9.11 section 10.9

Model size is a practical trade-off. Start with `small` when memory is limited, try `medium` with more unified memory, and choose `large-v3` only if its accuracy benefit warrants the extra memory and latency. section 9.11

How Build Applications with Local AI Models on a Mac covers it

How deep it goes
Defines ASR, outlines Whisper’s encoder-decoder process, and gives audio requirements and a transcription call; it does not derive model internals.
Examples
Uses a microphone transcription script and a browser chat interface that turns recorded speech into an LLM prompt.
What it assumes
Introduces AI and terminal concepts from zero; benefits from basic Python fundamentals when coding begins.
What you can do after
Build it from scratch with Python and MLX Whisper to transcribe microphone recordings and feed their text into a local chat application.
How it connects
Links spectrograms and encoder-decoder transformers to audio capture, LLM inference, and web interfaces.

Also explained in

Compare how 6 books explain speech recognition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Applications with Local AI Models on a Mac. The section links point to the parts of the book it draws on.