ferrum_engine/
transcription_engine.rs1use async_trait::async_trait;
4use ferrum_interfaces::engine::{InferenceEngine, TranscribeEngine};
5use ferrum_models::WhisperModelExecutor;
6use ferrum_types::{EngineConfig, EngineMetrics, EngineStatus, Result};
7use std::sync::Arc;
8
9pub struct TranscriptionEngine {
10 executor: Arc<WhisperModelExecutor>,
11 config: EngineConfig,
12}
13
14impl TranscriptionEngine {
15 pub fn new(executor: WhisperModelExecutor, config: EngineConfig) -> Self {
16 Self {
17 executor: Arc::new(executor),
18 config,
19 }
20 }
21}
22
23#[async_trait]
24impl InferenceEngine for TranscriptionEngine {
25 async fn status(&self) -> EngineStatus {
26 crate::modality_stubs::inert_status()
27 }
28
29 async fn shutdown(&self) -> Result<()> {
30 Ok(())
31 }
32
33 fn config(&self) -> &EngineConfig {
34 &self.config
35 }
36
37 fn metrics(&self) -> EngineMetrics {
38 crate::modality_stubs::inert_metrics()
39 }
40
41 async fn health_check(&self) -> ferrum_types::HealthStatus {
42 crate::modality_stubs::inert_health()
43 }
44}
45
46#[async_trait]
47impl TranscribeEngine for TranscriptionEngine {
48 async fn transcribe_file(&self, path: &str, language: Option<&str>) -> Result<String> {
49 self.executor.transcribe_file(path, language)
50 }
51
52 async fn transcribe_bytes(&self, data: &[u8], language: Option<&str>) -> Result<String> {
53 self.executor.transcribe_bytes(data, language)
54 }
55}