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, audio: AudioSamples, options: TranscriptionOptions, ) -> Result { tokio::task::spawn_blocking(move || { engine.transcribe_sync(&audio, &options) }) .await .map_err(|e| { KonError::TranscriptionFailed(format!("Task join error: {e}")) })? }