pub struct TtsEngine { /* private fields */ }Expand description
Main TTS engine for speech synthesis from GGUF models.
Implementations§
Source§impl TtsEngine
impl TtsEngine
Sourcepub async fn with_options<P: AsRef<Path>>(
gguf_path: P,
tokenizer_path: Option<P>,
voices_dir: Option<P>,
) -> Result<Self>
pub async fn with_options<P: AsRef<Path>>( gguf_path: P, tokenizer_path: Option<P>, voices_dir: Option<P>, ) -> Result<Self>
Create a new TTS engine with custom options.
§Arguments
gguf_path- Path to the Q4 GGUF model filetokenizer_path- Optional path to tokenizer JSON (auto-discovered if None)voices_dir- Optional path to voices directory (defaults to models/voxtral-tts/voice_embedding)
Sourcepub fn synthesize(
&mut self,
text: &str,
voice: Option<&str>,
) -> Result<AudioBuffer>
pub fn synthesize( &mut self, text: &str, voice: Option<&str>, ) -> Result<AudioBuffer>
Sourcepub fn synthesize_with_options(
&mut self,
text: &str,
voice: Option<&str>,
speed: f32,
gain: f32,
language: Option<&str>,
) -> Result<AudioBuffer>
pub fn synthesize_with_options( &mut self, text: &str, voice: Option<&str>, speed: f32, gain: f32, language: Option<&str>, ) -> Result<AudioBuffer>
Synthesize speech with custom options.
§Arguments
text- The text to synthesizevoice- Optional voice name (defaults to “casual_female”)speed- Playback speed multiplier (0.5 to 3.0, where 1.0 is normal)gain- Volume gain multiplier (0.1 to 2.0, where 1.0 is normal)language- Optional language code (e.g., “en”, “fr”, “de”)
§Returns
An audio buffer containing the synthesized speech at 24kHz.
§Speed Behavior
Speed adjustment uses resampling which changes both tempo and pitch. Higher speeds result in higher pitch (chipmunk effect), lower speeds result in lower pitch.
§Example
let mut tts = TtsEngine::new("models/voxtral-tts-q4.gguf").await?;
let audio = tts.synthesize_with_options(
"Hello world!",
None, // voice: None = default "casual_female"
2.0, // speed: 2.0 = twice as fast
0.8, // gain: 0.8 = 20% quieter
Some("en") // language
)?;Sourcepub fn list_voices(&self) -> Result<Vec<String>>
pub fn list_voices(&self) -> Result<Vec<String>>
List available voice presets in the voices directory.
§Returns
A vector of voice names, or an error if the directory doesn’t exist.
Sourcepub fn set_max_frames(&mut self, max_frames: usize)
pub fn set_max_frames(&mut self, max_frames: usize)
Set the maximum number of audio frames to generate.
Default is 2000 frames. Higher values allow longer audio generation.
Sourcepub fn set_euler_steps(&mut self, steps: usize)
pub fn set_euler_steps(&mut self, steps: usize)
Set the number of Euler ODE steps for flow matching (quality vs speed tradeoff).
- 3 steps: Real-time performance
- 4 steps: Balanced (default)
- 8 steps: Higher quality
Auto Trait Implementations§
impl !Freeze for TtsEngine
impl !RefUnwindSafe for TtsEngine
impl !Sync for TtsEngine
impl !UnwindSafe for TtsEngine
impl Send for TtsEngine
impl Unpin for TtsEngine
impl UnsafeUnpin for TtsEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more