fleetforge_runtime/gateway/
speech.rs1use anyhow::Result;
4use async_trait::async_trait;
5
6#[async_trait]
8pub trait SpeechToText: Send + Sync {
9 async fn transcribe(&self, audio_bytes: &[u8], lang: Option<&str>) -> Result<String>;
10}
11
12#[async_trait]
14pub trait TextToSpeech: Send + Sync {
15 async fn synthesize(&self, text: &str, voice: Option<&str>) -> Result<Vec<u8>>;
16}
17
18pub struct NoopStt;
20
21#[async_trait]
22impl SpeechToText for NoopStt {
23 async fn transcribe(&self, _audio: &[u8], _lang: Option<&str>) -> Result<String> {
24 Ok(String::from("transcript (noop)"))
25 }
26}
27
28pub struct NoopTts;
30
31#[async_trait]
32impl TextToSpeech for NoopTts {
33 async fn synthesize(&self, text: &str, _voice: Option<&str>) -> Result<Vec<u8>> {
34 Ok(format!("AUDIO({})", text).into_bytes())
35 }
36}