Connecting Your iPhone Keyboard to Self-Hosted Ollama: Diction Voice Input in Practice

Addressing the chronic privacy vulnerabilities of mobile voice dictation and cloud AI text correction through the self-hosted architecture of Diction. Examining the pipeline spanning iOS keyboard extensions, local Whisper transcription, and Ollama small language model cleanup, while benchmarking latency across local Wi-Fi and Tailscale tunnels.

Connecting Your iPhone Keyboard to Self-Hosted Ollama: Diction Voice Input in Practice

Who really intercepts what you type on your smartphone?

Privacy leaks remain genuine hazards.

Relying on mobile voice dictation and AI text polish has become second nature for countless engineers.

Yet the privacy compromises are severe.

Commercial keyboards consistently demand full access permissions under the premise of maintaining speech accuracy; every keystroke, raw audio packet, and clipboard snapshot is transmitted in real time to remote public cloud clusters.

Keyboards represent the single most dangerous privacy funnel on any smartphone.

Who feels comfortable typing root passwords or sensitive corporate data into a proprietary keyboard?

Virtually nobody.

Community developer Better-Psychology-42 introduced an engineering solution through the open-source Diction project.

The foundational design is straightforward: deploy the speech-to-text and AI text refinement gateway entirely on your self-hosted hardware.

The phone retains only clean keyboard interaction.

Architecture Breakdown: A Three-Tier Pipeline Keeping Data Private

Diction structures its architecture into three distinct layers.

The first layer is the iOS keyboard extension. This layer adheres to strict on-device sandboxing: standard QWERTY keystrokes, swipe typing gestures, and local spell-checking operate entirely inside the iPhone sandbox; the keyboard initiates an audio capture stream only when the user explicitly holds down the microphone key.

Background data leaks are strictly prevented.

The second layer is the self-hosted backend gateway. Compressed raw audio streams from the handset travel over a secure tunnel to your private server, where an integrated Whisper engine transcribes speech into unpunctuated text within milliseconds.

Local transcription is extraordinarily fast.

The third layer is the local model inference backend. The gateway communicates with an internal Ollama instance via standard HTTP endpoints; the compact model restores punctuation, rectifies disfluencies, and strips verbal crutches in under a few hundred milliseconds, streaming structured text back into the active mobile cursor.

The entire pipeline supports any OpenAI-compatible API endpoint.

Where does user data actually stay?

Keystrokes remain on-device. Audio stays on your home server. Zero commercial cloud vendors can observe your conversations.

Why 4B Compact Models Are the Sweet Spot for Keyboard Refinement

Many builders instinctively attempt to deploy oversized 70B parameter models onto home servers.

For mobile input, 4B models are far more efficient.

Keyboard text cleanup is fundamentally distinct from long-form open-ended conversation.

It represents a constrained sequence-to-sequence correction workload: inserting missing commas and periods; stripping oral filler words such as um, uh, or you know; resolving phonetic homophones; formatting stray digits and capitalization cleanly.

Does such straightforward correction require massive multi-step reasoning models?

Clearly not.

Oversized models on mobile devices introduce devastating latency.

Why is latency so critical?

Time to first token is simply too long.

When typing on a mobile touchscreen, human tolerance for input hesitation tops out around 1.5 to 2 seconds; if a user speaks a phrase and waits four or five seconds staring at a frozen cursor on the sidewalk, the workflow collapses.

Excessive waiting ruins typing rhythm.

Benchmarking a modest RTX-3060 graphics card with 12GB VRAM demonstrates the contrast: running a Qwen3.5-4B tier model inside Ollama at FP16 or Q8_0 quantization, with context hard-capped at 512 tokens; model forward inference claims just 180 milliseconds per token, finishing the entire revision within 400 milliseconds.

Processing speed is swift.

Factoring in local network transport and Whisper processing overhead, total end-to-end latency stays firmly near 1.3 seconds.

The tactile response feels instant.

Deployment Walkthrough: Tailscale Tunnels and Strict Prompt Rules

What engineering realities emerge when deploying this stack at home?

The initial challenge involves network ingress.

Mobile devices spend most of their operational lifecycle on cellular carriers.

Exposing an unauthenticated Ollama port directly to the public web is reckless; establishing encrypted connectivity via Tailscale or WireGuard overlays is the standard recommendation.

Field tests over 5G cellular connected to a residential Tailscale node added a negligible 35 milliseconds of round-trip latency; the responsiveness remains indistinguishable from home Wi-Fi.

Connection stability is rock solid.

The second critical factor is enforcing anti-chatter rules inside the system prompt.

General-purpose models frequently append polite conversational boilerplate: Certainly, here is your corrected text; or concluding with hope this assists your task.

If a model injects social courtesies inside a rapid messaging thread, the keyboard extension pastes that junk directly into the active field, disrupting communication completely.

Engineering the gateway requires absolute prompt rigidity:

You are a text cleanup engine. 
Task: Fix grammar, add punctuation, remove filler words like um/uh/er. 
Rule: Output ONLY the cleaned text. Never add explanations or greetings.

Conversational small talk must be forbidden.

The model acts strictly as a deterministic text filter.

Operational Boundaries and Trade-Offs

Is this architecture without compromises?

Certainly not.

Real-world usage highlights several non-negotiable engineering constraints:

First is VRAM retention versus cold-start penalty. If your server runs concurrent background workloads that cause Ollama to evict the 4B model into host memory, the initial voice invocation incurs a jarring 4-second loading delay. The remedy is setting keep_alive indefinitely:

curl http://localhost:11434/api/generate -d '{"model": "qwen3.5:4b", "keep_alive": -1}'

This locks model weights permanently into GPU memory.

Second is the stringent memory ceiling for iOS keyboard extensions. Apple enforces strict resident memory caps on third-party input extensions, typically between 50MB and 70MB. Executing audio encoding or excessive buffering on the handset triggers instantaneous operating system terminations; heavy processing must be pushed upstream to the server.

Third is offline degradation. What happens when entering an underground garage or dead zone without network reception? Diction handles offline fallbacks cleanly; the moment connectivity drops, AI enrichment steps aside, leaving native QWERTY typing intact without blocking input.

Keyboard streams represent personal privacy territory.

Keeping data sovereignty in your own hands; powering mobile inputs via self-hosted hardware; does this sense of control not make self-hosting genuinely rewarding?

💬 Discussion

GitHub Powered