llm/stt/mod.rs
1use crate::error::LLMError;
2use async_trait::async_trait;
3
4/// Trait implemented by all speech to text backends
5///
6/// This trait defines the interface for speech-to-text conversion services.
7/// Implementors must provide functionality to convert audio data into text.
8#[async_trait]
9pub trait SpeechToTextProvider: Send + Sync {
10 /// Transcribe the given audio bytes into text
11 ///
12 /// # Arguments
13 ///
14 /// * `audio` - A vector of bytes containing the audio data to transcribe
15 ///
16 /// # Returns
17 ///
18 /// * `Result<String, LLMError>` - On success, returns the transcribed text as a String.
19 /// On failure, returns an LLMError describing what went wrong.
20 async fn transcribe(&self, audio: Vec<u8>) -> Result<String, LLMError>;
21
22 #[allow(unused)]
23 async fn transcribe_file(&self, file_path: &str) -> Result<String, LLMError> {
24 Err(LLMError::ProviderError(
25 "Phind does not implement speech to text endpoint yet.".into(),
26 ))
27 }
28}