DEVELOPMENT JOURNEY

Timeline

Tiny Talk was built as a sequence of small sub-projects, each with a written design spec before any code. Along the way, there were interesting failures and learnings, four of which I describe below.

BUILD ORDER · ONE SPEC PER SUB-PROJECT
  1. Voice / dialog pipelineinterruptible speech I/O, built first on purpose
  2. iOS phone clienton-device VAD, AEC, real hardware only
  3. Story generation enginenarrative arc + deterministic safety scaffolding
  4. Animal facts retrievalfetch once per animal, cache forever
  5. Object recognitioncamera → on-device Vision → story guidance
  6. Child-facing UIonboarding, landing, story, library, reading, the end
  7. Storybook persistencetranscript → picture-book prose, saved
  8. Story length settingsparent-adjustable turns and pages
  9. Away-from-home demo modehosted models behind one switch
  10. Storybook page artlocal diffusion, character-consistent
  11. Pipelined TTS playbackspeak sentence one while two synthesises
  12. Library + reading screenswired to the real API, mocks removed
  13. Demo mode parityclose the gap the other sub-projects opened

The voice pipeline came first because interruptible, low-latency speech was what I most wanted to learn, and everything after it had to fit around what that pipeline cost.

REALTIME FACTOR

You can't ask a five-year-old to talk more slowly

If the audio transcriber takes longer than a second to decode a second of speech, the backlog keeps growing and never recovers, because there's no slack in the system to catch up.

Kyutai STT 1b · keeps up 0.77× realtime · 23% headroom

Every second of audio is decoded in 0.77 s. The queue drains. Utterance-end flush: 1.1 s. Memory footprint: 2.6 GB.

Kyutai STT 2.6b · falls behind without bound 1.7–2.3× slower than realtime

Utterance-end flush: 5.6–7.5 s. Footprint: 5.7 GB, with several hundred MB of it swapped out on a 16 GB machine also holding the LLM and TTS. Worst single decode frame: 1682 ms for 80 ms of audio, against 92 ms for a resident model.

The fix was to choose a model that fits the constraint, then make it hard to break the constraint by accident. A probe tool now measures realtime factor and swap pressure on demand and exits non-zero if the configured model can't keep up, so a future model swap gets checked against a measurement.

FOUR CASE STUDIES

Four bugs and respective learnings

Open one to see the full story.

01 “The app randomly disconnects” was really a throughput problemReconnection logic was never going to fix this one

THE PROBLEM

Sessions would die, seemingly at random, forty seconds into a conversation. It looked like a networking bug: a flaky WebSocket, or something iOS does when backgrounding.

WHY IT WAS HARD

It presented as a transport failure but originated three layers away, in model choice. The transcriber was decoding slower than realtime, so audio piled up unprocessed. That backlog paused the TCP socket; with the socket paused, the keepalive PONG went unread; and the server, seeing no PONG, correctly concluded a dead client and hung up on a perfectly healthy phone. None of the symptoms pointed at the transcriber.

WHAT WAS CONSIDERED

Decoupling the socket read loop from processing was the intuitive fix, and it was applied. It worked, in the narrow sense: the disconnects stopped. But instead of disconnecting, the app now hung, because the backlog was still growing and the turn never began. At that point it was clear nothing downstream could fix it.

WHAT WORKED

The 2.6b transcription model was replaced with the 1b, measured at 0.77× realtime against the 2.6b's 1.7–2.3× slower-than-realtime, which also freed 3.1 GB on a machine already holding two other models. The smaller model is less accurate, but that's a fine trade when the alternative is turns that never finish. A probe tool was then written that measures the configured model's realtime factor and swap pressure, and exits non-zero if it cannot keep up.

WHAT IT TAUGHT ME

In a realtime system, falling below 1× means the backlog grows forever, and the failure shows up in whichever component breaks first. The code change fixed it this time; the probe is what stops it from coming back.

02 A three-minute silence, and the model was only thinkingA latency bug that looked like memory pressure for weeks

THE PROBLEM

Replies would occasionally take minutes, or come back empty. With three models sharing 16 GB, memory pressure was the natural suspect, and swap statistics supported it.

WHY IT WAS HARD

Two plausible causes were entangled. Swapping was genuinely happening and genuinely harmful, so every measurement seemed to confirm the memory theory. Meanwhile the app's own logs showed nothing between request and reply.

WHAT WAS CONSIDERED

The first response was to reduce the model: a 4B instead of the 9B. That helped a little, which was misleading because it looked like confirmation. What finally worked was running the model directly from the command line with one short prompt, outside the app.

WHAT WORKED

That run produced over a hundred lines of internal chain-of-thought and took about three minutes and nineteen seconds before emitting a single word of reply. The model defaults to a "thinking mode" this app doesn't need, since each reply is one to three spoken sentences. Thinking can be turned off per request, so I switched back to the 9B and kept its better replies. Keep-alive was separately stretched to thirty minutes, because under memory pressure the runtime evicts the model and the next request pays a multi-gigabyte reload.

WHAT IT TAUGHT ME

When two candidate causes both look right, stop instrumenting the system and go measure the dependency on its own. Also, making a symptom smaller doesn't mean you're getting closer to the cause. Shrinking the model only looked like progress.

03 A segfault in PyTorch that was my own race conditionIssue #34: a crash in someone else's code, caused by mine

THE PROBLEM

The server would hard-crash with a SIGSEGV inside an LSTM kernel on Apple's Metal backend, deep in a third-party library, with no Python traceback worth reading.

WHY IT WAS HARD

Every signal pointed outward. A native crash inside someone else's tensor kernel makes you want to blame the kernel, the backend or the OS. There was also an easy workaround, since moving speech synthesis to CPU avoids that kind of crash entirely. But taking it would have hidden a real bug in this codebase.

WHAT WAS CONSIDERED

Falling back to CPU was measured and kept in reserve: it costs roughly 0.3 s of extra latency to first audio, with synthesis still running about 4.5× faster than realtime. I didn't want to use it until I understood the crash.

WHAT WORKED

The real cause was in this project's own synthesis module: when a synthesis was cancelled (which happens every time a child barges in), the Metal cache was being released from a second, unlocked thread while the cancelled synthesis was still running on the worker. So the race only fired during interruptions, which is the main thing the app does. The fix was to do the release under the lock. CPU is still available as a configured fallback, but it isn't the fix.

WHAT IT TAUGHT ME

A crash inside a dependency tells you where memory was touched, but it doesn't tell you whose bug it is. And a workaround that works can cause a concurrency bug in your own code without ever finding it.

04 Barge-in broke three more times after it workedAny change to playback could break interruption

THE PROBLEM

Allowing kids to interrupt the storyteller mid-sentence was a key goal for the project, so we verified it working on real hardware early. Then it broke repeatedly, each time because of a change that didn't seem to have anything to do with it.

WHY IT WAS HARD

Barge-in depends on the whole loop, so a change almost anywhere can break it. Pipelined playback (speaking sentence one while sentence two is still synthesising) was a clear latency win, but it let the session look idle between buffers, so an interrupt arriving in that window found nothing to cancel. A hang-guard timer measured its deadline from when an audio buffer was scheduled rather than when its turn to play actually began, so it could declare the storyteller finished while she was still talking. And interrupting the story's final reply could strand the child with no reply and no ending screen at all.

WHAT WAS CONSIDERED

Each of these could have been patched on its own with a longer timer, a guard flag or a special case for the last turn. But all three came from the same mix-up between what the system had scheduled and what the child had actually heard.

WHAT WORKED

The fixes all track what's been heard. Playback state now reflects audible progress rather than scheduling progress; the hang guard starts from the moment a buffer's turn to play begins; and the end-of-story path handles interruption as a normal case rather than an exception. A latched flag means a story concluded during an interrupted turn saves on the next completed turn instead of being lost or duplicated. All confirmed by hand on a real phone, along with one more bug found during that same testing session, where the ending screen failed to re-arm for a second story.

WHAT IT TAUGHT ME

If something has to stay true across the whole app, give it a name, or nobody will remember to continually check it. Here, that was the gap between what the system scheduled and what the child heard. Every timer should be measured against what the child heard, not what the system thought it had played.

HOW THINGS ACTUALLY GOT VERIFIED

There is no CI that can hear a child interrupt

Tests only check the logic

The server test suite is large and useful. It catches protocol regressions, state-machine holes and parser edge cases. It cannot tell you whether barge-in feels instant, whether echo cancellation stops the storyteller interrupting itself, or whether a voice sounds warm.

So “done” means on-device

The project's working rules say every change needs device-test instructions: which worktree, whether the server needs restarting, whether the phone needs rebuilding, and a numbered script of what to say and what confirms it worked. “Tests pass” isn't enough.

So human time is the bottleneck

If every fix needs a person, a phone and a five-year-old, then testing takes more time than coding. That shaped the workflow on the next page.

Tiny Talk was co-developed by Jessica Van Brummelen and Claude.