Skip to content

refactor(transcription): introduce AsrEngine trait (Track-B foundation)#9

Open
farce1 wants to merge 1 commit into
mainfrom
feat/asr-engine-trait
Open

refactor(transcription): introduce AsrEngine trait (Track-B foundation)#9
farce1 wants to merge 1 commit into
mainfrom
feat/asr-engine-trait

Conversation

@farce1

@farce1 farce1 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

What — Track-B step 1 of N

The foundation for pluggable ASR engines (the path to Parakeet-TDT-v3). A behavior-preserving refactor that puts the existing sherpa Whisper recognizer behind a small trait:

pub trait AsrEngine {
    fn transcribe(&mut self, sample_rate: u32, samples: &[f32]) -> AsrOutput; // { text, language }
}
  • New transcription/engine.rs: AsrEngine, AsrOutput, WhisperEngine (wraps WhisperRecognizer).
  • worker.rs now drives a Box<dyn AsrEngine> (loses ~14 lines; engine construction moved into engine.rs). The VAD → chunk → transcribe loop was already engine-agnostic.
  • Behavior-preserving: identical WhisperConfig (lang auto, 2 threads, CPU) and identical text/language mapping.

A new engine (Parakeet) now plugs in by implementing AsrEngine + a loader — no further worker.rs surgery.

Verification (TDD)

  • engine.rs test: trait is object-safe and returns engine output (via a FakeEngine, which also demonstrates the Parakeet extension point).
  • clippy --all-targets --all-features -- -D warnings ✅; full cargo test → only the pre-existing model_archive_consts_tests (REPLACE_WITH_ placeholders) fail.

Track-B roadmap (this is step 1)

  1. AsrEngine trait ← this PR
  2. ParakeetEngine via sherpa-rs OfflineRecognizer (transducer) — Parakeet-TDT-v3
  3. Model registry + download for Parakeet
  4. Engine-selection setting + plumbing (default Parakeet-v3, Whisper-turbo fallback)
  5. Model-picker UI
  6. GPU execution providers (separate, larger)
  7. retranscribe_meeting over stored OGG

Merge note

worker.rs overlaps with the Track-A PRs #4 (segment construction), #6 (resampler/sample-rate), #8 (panic-guard wraps the transcribe call). Integration: the panic-guard should wrap engine.transcribe, and build_segment_result consumes AsrOutput. Suggest merging Track-A first, then rebasing this.

⚠️ CI red on maintainer-only blockers (vendor binary + REPLACE_WITH_ placeholders), not this PR. Code-only, no new deps (Parakeet will reuse sherpa-rs).

… recognizer

Foundation for pluggable ASR engines (Parakeet-TDT-v3 next). Extracts the sherpa
Whisper recognizer into transcription/engine.rs behind a small AsrEngine trait
(transcribe(samples) -> AsrOutput { text, language }); the worker now drives a
Box<dyn AsrEngine>. Behavior-preserving — same WhisperConfig and field mapping;
the VAD -> chunk -> transcribe loop was already engine-agnostic.
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