Schema enrichment: - transcripts table: +engine, +model_id, +inference_ms, +sample_rate, +audio_channels, +format_mode, +remove_fillers, +british_english, +anti_hallucination - New error_log table: context, error_code, message, metadata (JSON) - 5 indices on frequently queried columns Metadata pipeline: - TranscriptMetadata struct in kon-core for full provenance capture - LocalEngine tracks loaded ModelId, returns TimedTranscript with inference_ms - std::time::Instant timing around transcribe-rs inference calls - Tauri transcription commands emit inference_ms in event payloads - InsertTranscriptParams accepts all provenance fields - log_error() for structured error logging to SQLite Every transcript is now fully reproducible from its stored metadata. 23 tests passing, clippy clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
688 B
Rust
23 lines
688 B
Rust
use std::sync::Arc;
|
|
|
|
use kon_core::error::{KonError, Result};
|
|
use kon_core::types::{AudioSamples, TranscriptionOptions};
|
|
|
|
use crate::local_engine::{LocalEngine, TimedTranscript};
|
|
|
|
/// 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<TimedTranscript> {
|
|
tokio::task::spawn_blocking(move || {
|
|
engine.transcribe_sync(&audio, &options)
|
|
})
|
|
.await
|
|
.map_err(|e| {
|
|
KonError::TranscriptionFailed(format!("Task join error: {e}"))
|
|
})?
|
|
}
|