Skip to main content

Synthesizer

Trait Synthesizer 

Source
pub trait Synthesizer:
    Send
    + Sync
    + 'static {
    // Required methods
    fn sample_rate(&self) -> u32;
    fn synthesize_with(
        &self,
        text: &SpeechText,
        voice: Option<&Voice>,
        rate: SpeakingRate,
        out: SpeechWriter,
        cancel: &CancelToken,
    ) -> Result<(), SynthesisError>;

    // Provided method
    fn plays_audio_itself(&self) -> bool { ... }
}
Expand description

The contract every text-to-speech engine implements.

An implementation must:

Required Methods§

Source

fn sample_rate(&self) -> u32

The rate of the PCM this engine writes, fixed by its model.

Source

fn synthesize_with( &self, text: &SpeechText, voice: Option<&Voice>, rate: SpeakingRate, out: SpeechWriter, cancel: &CancelToken, ) -> Result<(), SynthesisError>

Synthesizes speech into out, chunk by chunk. voice of None means the engine’s configured default.

Provided Methods§

Source

fn plays_audio_itself(&self) -> bool

Whether this engine delivers sound itself rather than writing PCM: a platform voice program synthesizes and plays in one stroke. Synthesis::speak skips its own playback for such an engine. A wrapper around another synthesizer must forward this, or start hands back an empty session instead of refusing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Synthesizer + ?Sized> Synthesizer for Arc<T>

A shared engine synthesizes like the engine itself.

Source§

impl<T: Synthesizer + ?Sized> Synthesizer for Box<T>

Implementors§