Skip to main content

TTSEngine

Trait TTSEngine 

Source
pub trait TTSEngine: Send + Sync {
    // Required methods
    fn synthesize<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
        voice: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn synthesize_stream<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
        voice: &'life2 str,
        callback: Box<dyn Fn(Vec<u8>) + Sync + Send>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn list_voices<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VoiceInfo>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn name(&self) -> &str;
    fn as_any(&self) -> &(dyn Any + 'static);
}
Expand description

Abstract TTS engine trait for extensibility

Required Methods§

Source

fn synthesize<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, voice: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Synthesize text to audio data

Source

fn synthesize_stream<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, voice: &'life2 str, callback: Box<dyn Fn(Vec<u8>) + Sync + Send>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Synthesize with streaming callback for long texts

Source

fn list_voices<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<VoiceInfo>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

List available voices

Source

fn name(&self) -> &str

Get engine name

Source

fn as_any(&self) -> &(dyn Any + 'static)

Get as Any for downcasting to engine-specific types

This allows accessing engine-specific methods like stream_receiver() on KokoroTTS after downcasting.

Implementors§