Files
Lumotia/crates/transcription/Cargo.toml
Jake 8b49d0fe9c feat(A.2 #13): replace SpeechBackend enum with Transcriber trait
New crates/transcription/src/transcriber.rs defines a Transcriber
trait (Send supertrait for spawn_blocking travel) with
TranscriberCapabilities (sample_rate, channels, supports_initial_prompt).
TranscriberCapabilities.sample_rate is load-bearing for the upcoming
progressive WAV writer (#19).

Concrete impls:
- SpeechModelAdapter wraps Box<dyn transcribe_rs::SpeechModel + Send>
  for Parakeet (and any future transcribe-rs-backed engine).
- WhisperRsBackend moves its transcribe_sync body into the impl,
  widening the signature from &self to &mut self so per-call
  WhisperState can be created cleanly through the trait object.

LocalEngine now holds Box<dyn Transcriber + Send>; dispatch in
transcribe_sync collapses from a match to a direct call. Adds
LocalEngine::capabilities() for the WAV-writer.

Cargo feature flag "whisper" (default on) makes whisper-rs, num_cpus,
and the whole whisper_rs_backend module optional. cargo check
--no-default-features -p kon-transcription now builds without pulling
whisper-rs-sys — the escape hatch brief item #6 / #13 called for on
Windows / non-AVX2 / cloud-only builds. load_whisper is cfg-gated
behind the same feature.

src-tauri/src/commands/models.rs load_model_from_disk returns
Box<dyn Transcriber + Send> instead of SpeechBackend; caller chain
(ensure_model_loaded, prewarm_default_model) is unchanged.

transcriber_trait_is_object_safe test lands alongside the trait as a
compile-time witness against future Self-returning / generic-method
additions.
2026-04-22 04:33:23 +01:00

52 lines
1.8 KiB
TOML

[package]
name = "kon-transcription"
version = "0.1.0"
edition = "2021"
description = "Speech-to-text engine wrappers, model management, and inference concurrency for Kon"
build = "build.rs"
[features]
# Whisper backend (direct whisper-rs, vulkan-accelerated). Default on —
# gating it exists so a future Windows non-AVX2 build, or a cloud-only
# ASR configuration, can drop whisper-rs-sys entirely per brief item
# #13. Disabling this feature also drops the WhisperRsBackend module
# and the load_whisper entry point.
default = ["whisper"]
whisper = ["dep:whisper-rs", "dep:num_cpus"]
[dependencies]
kon-core = { path = "../core" }
# Parakeet via ONNX. Whisper is handled directly via whisper-rs below.
transcribe-rs = { version = "0.3", default-features = false, features = ["onnx"] }
# Async runtime for spawn_blocking
tokio = { version = "1", features = ["rt", "sync"] }
# Model downloads
reqwest = { version = "0.12", features = ["stream"] }
futures-util = "0.3"
# Download integrity verification
sha2 = "0.10"
# Gated behind the `whisper` feature (see [features] above).
whisper-rs = { version = "0.16", default-features = false, features = ["vulkan"], optional = true }
# Direct whisper-rs backend (WhisperRsBackend): thread pool sizing.
# Gated alongside whisper-rs since no other code in this crate needs it.
num_cpus = { version = "1", optional = true }
# Typed error enum used by WhisperRsBackend + elsewhere. Kept
# unconditional because it is a derive-macro crate with negligible
# build cost.
thiserror = "2"
# Structured logging at backend boundaries (observability for initial_prompt flow).
tracing = "0.1"
[dev-dependencies]
# TcpListener fixture for the download resume tests (mirrors kon-llm).
tokio = { version = "1", features = ["rt", "sync", "net", "io-util", "macros"] }
tempfile = "3"