use std::sync::Arc; use magnotia_core::error::{MagnotiaError, Result}; use magnotia_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| MagnotiaError::TranscriptionFailed(format!("Task join error: {e}")))? }