Skip to content

Replace whisper.cpp with sherpa-onnx (Silero VAD + Moonshine ASR) - #1

Merged
mtib merged 15 commits into
mainfrom
sherpa-onnx-refactor
May 20, 2026
Merged

mtib merged 15 commits into
mainfrom
sherpa-onnx-refactor

Conversation

@mtib

@mtib mtib commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the CWhisper/whisper.cpp stack with sherpa-onnx v1.12.20: Silero VAD (per-stream) + Moonshine base en-int8 (shared, CoreML/Metal-accelerated)
  • Adds tools/download-sherpa.sh for idempotent download of dylibs (~50 MB) and models (~150 MB); build.sh updated to bundle the real dylibs and copy sherpa-models into the app
  • Fixes a critical VAD bug: max_speech_duration was zero-initialized to 0.0, causing Silero's threshold to spike immediately on any speech and suppress all transcription output; fixed to 30.0
  • Adds crosstalk suppression (mic samples zeroed when system audio RMS active within 250 ms) and per-stream pending-buffer compaction to prevent unbounded growth

Test Plan

  • LIVETRANSLATE_SIGN_IDENTITY=LiveTranslateDev ./build.sh — build completes cleanly
  • open build/Al.app → grant mic + screen recording permissions
  • Speak a sentence; within ~500 ms of silence tail -f /tmp/al.log shows SherpaEngine[mic]: "…"
  • cat ~/.al/**/*.txt | tail -5 — transcribed lines appear
  • Stop, wait 5+ min, Start, speak — new file created in ~/.al/<date>/
  • ps -o rss,command -p $(pgrep -f 'build/Al.app') — RSS plateaus ~300 MB
  • Quit — log ends with Al: bye

🤖 Generated with Claude Code

mtib and others added 15 commits May 18, 2026 00:26
… models header

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…style

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all WhisperEngine references in Pipeline.swift with SherpaEngine.
Remove hallucination-phrase filters from TranscriptWriter (Silero VAD makes
them unnecessary); keep the punctuation-only guard. Update Utterance doc
comment in Types.swift to reflect SherpaEngine authorship.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace whisper.cpp build step with sherpa-onnx: call download-sherpa.sh,
copy real dylibs into Contents/Frameworks/, patch rpath with
@executable_path/../Frameworks, and bundle sherpa-models into Resources.
Remove tools/build-whisper.sh. Also fix CSherpa header relative path
(../../../ → ../../) to match actual project layout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- SherpaEngine: set silero.max_speech_duration = 30.0 (zero-init caused
  VAD threshold to spike immediately on any speech, suppressing all output)
- Pipeline: log call-stack on stop() entry to aid future diagnostics
- tools/download-sherpa.sh: fix CSherpa forwarding header to use ../../../
  (Sources/CSherpa/include/ is 3 levels from repo root, not 2)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Silero closes segments after 500 ms of silence, so continuous speech
was being split into many short lines. Now utterances arriving within
3 seconds of each other are joined with a space on the same line.
A newline is emitted when the gap exceeds the threshold, and flush()
terminates the final line before the file is closed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ts/al

- Replace Moonshine base en int8 with NeMo Parakeet TDT 0.6B v3 int8 via
  sherpa-onnx (transducer config + model_type=nemo_transducer, CoreML EP).
  Higher accuracy English ASR; ~4× larger model (~600 MB unpacked).
- Move transcript output from ~/.al/ to ~/Documents/al/ in both
  TranscriptWriter and the menu-bar "Open Log Folder" action.
Adds an opt-in pipeline: sealed-box encrypt each utterance on the client,
ship to a small FastAPI server, search across all clients by text + dense
embedding from the new Browse window. Everything keyed by a pre-shared
key on every endpoint, including pubkey fetch.

Client (Sources/Al/):
- Settings.swift: UserDefaults-backed server URL, PSK, writeLocally
  toggle (default on), stable client UUID.
- Crypto.swift: X25519 ephemeral keypair + HKDF-SHA256 + ChaCha20-Poly1305
  sealed-box envelope; CryptoKit-only.
- LogShipper.swift: actor with JSONL outbox under Application Support,
  worker loop, pubkey refresh ahead of valid_until.
- OptionsWindow.swift / BrowserWindow.swift: SwiftUI windows for config
  and infinite-scroll hybrid search with document preview.
- AppDelegate.swift: install a hidden main menu so Cmd-C/V/A reach text
  fields in accessory mode.
- TranscriptWriter / MenuBarContentView: respect writeLocally toggle.
- SherpaEngine.swift: bump VAD min_silence_duration to 1.5 s.

Server (server/):
- FastAPI app with PSK on every endpoint, including /pubkey.
- Auto-rotating X25519 keys with valid_until and retention window;
  decrypts try every retained key.
- Server-side document grouping by temporal proximity across all
  clients; embeddings cached per text_hash.
- Endpoints: /pubkey, /logs, /search, /search/semantic, /search/hybrid,
  /documents, /document/{id}, /recent, /clients, /files/{...}.
- Dockerfile + docker-compose.yml.

CI (.github/workflows/server-image.yml):
- Build & push the server image to GHCR on changes under server/**.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mtib
mtib merged commit ab40811 into main May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant