Lesson 7: Voice & Call LAFINA
Goal of this lesson
Explain how LAFINA hears (STT), speaks (TTS), and holds a voice conversation. Know how online and offline Call LAFINA differ and the safety gates for the online one.
The voice building blocks
| Block | Offline | Online |
|---|---|---|
| Hearing (STT) | whisper.cpp tiny.en (quantized q5_1) + Silero VAD | ElevenLabs (live voice) |
| Speaking (TTS) | Phone’s speech engine via react-native-tts (needs an installed offline voice) | ElevenLabs voices through the backend |
| Thinking | Rule parser + optional on-device model | DeepSeek (via the backend) |
- VAD (Voice Activity Detection) tells LAFINA when you start and stop talking, so it knows when to transcribe.
- Whisper targets (in-app metrics): median about 1.5 s after you stop talking, 95th percentile under 3 s.
- Speech “ghosts”: LAFINA filters Whisper’s known hallucinations on silence and ignores its own voice echoing back.
- Kokoro is no longer used. The phone’s TTS starts faster and uses less memory.
Push-to-talk (in Chat)
Tap the mic Only after microphone permission
Record until a ~1 s pause Silero VAD
Whisper transcribes on the phone Editable draft before sending
Same pipeline as typed messages See Lesson 5
Call LAFINA: choosing the mode
Call LAFINA is a hands-free conversation that the student starts (unlike a reminder call, which LAFINA starts).
Student taps Call LAFINA
Signed in as this account?
Did NOT choose Offline Mode in Chat?
Internet available?
all yes
Online call All yes
any no
Offline call Shows the reason: signed out / chose offline / no internet / online unavailable
Online Call LAFINA
Local gates, in order Native support → signed in → Online Mode → consent → internet → mic permission
Server gates Capability check → backend creates a short-lived signed session
Signed WebSocket to ElevenLabs Live mic audio ↔ speech + transcripts
DeepSeek writes replies Through the backend's custom-LLM bridge
Tool calls run on the phone Read planner, prepare / revise draft cards, open a skill
Student ends the call Each finished turn saved once
Online call rules worth remembering
- Nothing reaches the network before the local gates pass.
- Each start gets a new generation. Late events from an old call are ignored and can’t reopen the mic.
- It never restarts by itself. Going to the background, a phone call, a network drop, or losing audio focus all require a new tap.
- Barge-in: if you interrupt, LAFINA stops talking and listens. An answer you didn’t hear fully is saved as interrupted.
- Persona: short spoken sentences, first person, no markdown. It never invents tool progress or saved actions, and treats notes as untrusted data.
- Saving still needs approval: the model prepares a draft card, and only the student’s explicit approval commits it.
- Skills: “make flashcards” → LAFINA ends the call and opens the skill. It doesn’t make them during the call.
Offline Call LAFINA
LAFINA speaks Phone TTS. Mic is CLOSED (half-duplex)
Ignore the first ~0.3 s Room echo of her own voice
Listen until a ~0.7 s pause Silero VAD (shorter than push-to-talk for snappier turns)
Whisper transcribes Filters echoes and hallucinations
Respond Same rules as chat: answer, review card, or save
Repeat Until End, 3 silent listens in a row, or 20 minutes
| Offline call limit | Value |
|---|---|
| Max call length | 20 minutes |
| Silent listens before hanging up | 3 |
| Capture errors before stopping | 2 |
| Max transcription time per utterance | 25 s |
| Max response time per turn | 20 s |
| End-of-speech pause | 0.7 s |
Both call types report the same snapshot to the UI, so the call screen, mini bar, and app-wide call registry work with either.
Check yourself
- Which engines handle STT and TTS offline and online?
- What does VAD do, and why is the call’s pause shorter than push-to-talk’s?
- What decides online vs. offline Call LAFINA? Can a call switch mid-way?
- List the local gates for the online call in order.
- What is half-duplex, and why does the offline call use it?
- How can the online model save something to the planner?