pub trait TtsProvider: Send + Sync {
// Required methods
fn synthesize<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<AudioFrame, AudioError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn synthesize_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<AudioFrame, AudioError>> + Send>>, AudioError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn voice_catalog(&self) -> &[Voice];
}Available on crate feature
audio only.Expand description
Unified trait for text-to-speech providers.
Implementors include cloud services (ElevenLabs, OpenAI, Gemini, Cartesia) and local models (MLX Kokoro, ONNX Kokoro).
Required Methods§
Sourcefn synthesize<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<AudioFrame, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn synthesize<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<AudioFrame, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Synthesize text to a single audio frame (batch mode).
Sourcefn synthesize_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<AudioFrame, AudioError>> + Send>>, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn synthesize_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 TtsRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<AudioFrame, AudioError>> + Send>>, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Synthesize text as a stream of audio frames (streaming mode).
Sourcefn voice_catalog(&self) -> &[Voice]
fn voice_catalog(&self) -> &[Voice]
List available voices for this provider.