feat(kon): add transcription crate — transcribe-rs wrapper, model manager
- LocalEngine wraps transcribe-rs SpeechModel behind Kon's own abstraction - load_parakeet() and load_whisper() factory functions - Unified model manager: download with progress callback, check, list, path resolution - Atomic downloads: .part suffix with rename on completion - run_inference() encapsulates spawn_blocking threading - Zero Tauri dependency in this crate (progress via callback, not events) - transcribe-rs v0.3.2 with onnx + whisper-cpp features - 4 tests passing, clippy clean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
20
crates/transcription/src/concurrency.rs
Normal file
20
crates/transcription/src/concurrency.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use kon_core::error::{KonError, Result};
|
||||
use kon_core::types::{AudioSamples, Transcript, TranscriptionOptions};
|
||||
|
||||
use crate::local_engine::LocalEngine;
|
||||
|
||||
/// Runs inference on a blocking thread. Encapsulates all threading concerns.
|
||||
/// Callers never see spawn_blocking — they call this async function.
|
||||
pub async fn run_inference(
|
||||
engine: Arc<LocalEngine>,
|
||||
audio: AudioSamples,
|
||||
options: TranscriptionOptions,
|
||||
) -> Result<Transcript> {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
engine.transcribe_sync(&audio, &options)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| KonError::TranscriptionFailed(format!("Task join error: {e}")))?
|
||||
}
|
||||
Reference in New Issue
Block a user