# Mac exercise for mission 13.1: Listening, thinking, speaking with a stopwatch

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/mac-13-1

About 25 minutes at your computer · Type this address: **llm.yoga/en/mac-13-1**

In the mission you put together a latency budget on paper. Here you build the chain yourself: Parakeet listens, qwen3:1.7b thinks, the built-in macOS voice speaks. Between the links there are files instead of streams. So this is the first line of the worked example, with no overlap at all.

**Before you start**

You need **Ollama** and Python 3 in the terminal. Ollama comes as an app: download it from ollama.com/download and drag it into your Applications folder. On first launch, the app asks permission, if needed, to set up the `ollama` terminal command. It requires macOS 14 or newer. More on this in [chapter 10](https://llm.yoga/en/10-lokale-modelle-4.md). Check:

```
ollama --version
```

You also need **parakeet-mlx**, the version of the Parakeet speech recognition model for Apple chips, in its own Python environment. It needs ffmpeg (for example via Homebrew).

```
python3 -m venv ~/sprache
```

```
source ~/sprache/bin/activate
```

```
pip install parakeet-mlx
```

(Checked against the documentation, not run here) On the test Mac, parakeet-mlx 0.7.0 was already set up in an environment like this, and so was ffmpeg. The chapter names `uv tool install parakeet-mlx -U` as a second route. On the first run, parakeet-mlx downloads the model parakeet-tdt-0.6b-v3 from Hugging Face, about 2.5 GB; on the test Mac that took a little over three minutes. All further commands run in the same terminal window with the environment activated.

### 1. Have a test question recorded

The macOS voice Anna speaks the question into a file. The question is in German, „Haben Sie am Freitag Nachmittag noch einen Termin frei?“ (“Do you have an appointment free on Friday afternoon?”), because the rest of the chain is German too. Then `afconvert` converts it to the format Parakeet expects: 16 kHz, mono, 16 bit.

```
say -v Anna -o frage.aiff "Haben Sie am Freitag Nachmittag noch einen Termin frei?"
```

```
afconvert -f WAVE -d LEI16@16000 -c 1 frage.aiff frage.wav
```

```
afinfo frage.wav | grep -E "Data format|estimated duration"
```

**Output (Measured on an M4 Mac (24 GB) on November 25, 2026)**

```
Data format:     1 ch,  16000 Hz, Int16
estimated duration: 3.273062 sec
```

### 2. Listen

`time` times the whole command. In the Mac’s zsh, the wall-clock time comes before the word `total`; in bash it’s called `real`.

```
time parakeet-mlx frage.wav --output-format txt
```

```
cat frage.txt
```

**Output, second run (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
parakeet-mlx frage.wav --output-format txt  1.44s user 2.09s system 69% cpu 5.098 total
Haben Sie am Freitagnachmittag noch einen Termin frei?
```

Recognized correctly, even with the correct German spelling „Freitagnachmittag“ as one word. The first run took 14.6 seconds, the third 4.6.

### 3. Think

A small model without a thinking phase, with a role and the recognized question. The prompt is in German; it tells the model it’s the phone assistant of a practice that is open Friday from 8 to 12, and asks it to answer the caller in one short spoken sentence. `--verbose` writes the measurements to the terminal, and the answer goes into `antwort.txt`.

```
time ollama run qwen3:1.7b --verbose --think=false "Du bist die Telefonassistenz einer Praxis. Geöffnet ist Freitag 8 bis 12 Uhr. Ein Anrufer fragt: $(cat frage.txt) Antworte ihm in einem kurzen gesprochenen Satz." > antwort.txt
```

```
cat antwort.txt
```

**Output, second run, shortened (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
total duration:       271.232125ms
load duration:        1.2845ms
prompt eval count:    77 token(s)
eval count:           16 token(s)
eval duration:        244.145ms
eval rate:            65.53 tokens/s
ollama run qwen3:1.7b --verbose --think=false  > antwort.txt  0.02s user 0.02s system 11% cpu 0.352 total
Ja, ich habe am Freitagnachmittag einen Termin frei.
```

Fast and wrong: „Ja, ich habe am Freitagnachmittag einen Termin frei“ means “Yes, I have an appointment free on Friday afternoon”, but the practice is only open until 12 on Fridays. A small model delivers the first token quickly but doesn’t reliably stick to the instructions. The model was already loaded, hence only 1 ms of load time.

### 4. Speak

The Mac voice reads the answer into a file, and `afplay` plays it.

```
time say -v Anna -o antwort.aiff "$(cat antwort.txt)"
```

```
afplay antwort.aiff
```

**Output, second run (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
say -v Anna -o antwort.aiff "$(cat antwort.txt)"  0.41s user 0.40s system 15% cpu 5.245 total
```

In the third run it was 2.4 seconds: under load, this varies a lot. The first run (1.4 seconds) doesn’t count, because there, with a different prompt, the model only repeated the question, so the voice spoke a different text. For this stage the chapter uses Piper with a German voice; Piper wasn’t installed on the test Mac, so the Mac voice takes on the same role.

### 5. Add it up

Add up the three times before `total`. In the output below, „zweiter Lauf“ and „dritter Lauf“ mean second and third run, with German decimal commas.

**Sums (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
zweiter Lauf: 5,098 + 0,352 + 5,245 = 10,695 s
dritter Lauf: 4,568 + 0,402 + 2,420 =  7,390 s
```

Seven to eleven seconds, where a person answers after 208 ms. The slowest link wasn’t the language model but listening and speaking. Ollama keeps its model in memory; Parakeet reloads it on every call.

### 6. Listen with the model loaded

A small script shows how much of that was loading: it loads Parakeet once and transcribes the same file three times. Save it as `hoeren.py` and run it in the activated environment. It prints „Laden“ (loading) and „Runde“ (round).

```
import sys, time
t0 = time.perf_counter()
from parakeet_mlx import from_pretrained
m = from_pretrained("mlx-community/parakeet-tdt-0.6b-v3")
print(f"Laden: {time.perf_counter() - t0:.2f} s")
for i in range(3):
    t = time.perf_counter()
    r = m.transcribe(sys.argv[1])
    print(f"Runde {i + 1}: {(time.perf_counter() - t) * 1000:.0f} ms  {r.text}")
```

```
python3 hoeren.py frage.wav
```

**Output (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
Laden: 2.11 s
Runde 1: 1802 ms  Haben Sie am Freitagnachmittag noch einen Termin frei?
Runde 2: 734 ms  Haben Sie am Freitagnachmittag noch einen Termin frei?
Runde 3: 423 ms  Haben Sie am Freitagnachmittag noch einen Termin frei?
```

With the model loaded, listening takes 0.4 seconds for 3.3 seconds of audio, close to the 300 ms from the worked example. That’s why real voice agents keep all models in memory all the time.

### 7. Let the page check it

Paste the measurements from step 3, ideally from two runs. The page compares the writing speed with the upper limit for qwen3:1.7b on an M4 and works out how long 40 tokens would take.

The check needs JavaScript. Without it: 65.5 and 58.7 tokens per second, 76 and 68 percent of 86.

### 8. Clean up

```
rm frage.aiff frage.wav frage.txt antwort.txt antwort.aiff hoeren.py
```

```
ollama stop qwen3:1.7b
```

If you no longer need Parakeet: `deactivate`, delete the folder `~/sprache`, and remove the model from the Hugging Face cache, the folder `~/.cache/huggingface/hub/models--mlx-community--parakeet-tdt-0.6b-v3`. Keep both if you’re still doing the exercise for 13.3. (Checked against the documentation, not run here)

With 16 GB it works the same way. With 8 GB, use qwen3:0.6b instead of qwen3:1.7b and close other programs. Something to think about: which link would streaming shorten the most for you?

#### On the DGX Spark

NVIDIA’s Spark overview has no dedicated playbook for speech. A split chain is doable: the language model runs on the Spark, set up with the playbook “Chat with LLMs Using Open WebUI and Ollama”, and can be much bigger there, for example gpt-oss:20b. Listening and speaking stay on the Mac as above; you send the call from step 3 via REST to the Spark instead of to localhost. Then compare whether the bigger model respects the opening hours and what it costs in waiting time. (Checked against the documentation, not run here)
