Expand description
A safe Rust wrapper around espeak NG via espeakNG-sys.
Safety
This library wraps the internal C calls in a singleton (Speaker) to keep the mutable global state safe.
In this future this may be changed to use the asynchronous features of espeakNG
however I currently don’t
trust it to be safe without a global lock.
The raw bindings are re-exported via the bindings module however usage of this is unsafe
and all safety guarantees of the Speaker object are considered broken if used.
Known Issues
Speaker::synthesize
seems to emit broken WAV audio data, no idea how to fix.
Examples
Generating phonemes from text:
fn main() -> Result<(), espeakng::Error> {
// Get a reference to the global Speaker singleton, using default voice path and buffer length.
let mut speaker = espeakng::initialise(None)?.lock();
// Generate the phonemes in standard mode.
let phonemes = speaker.text_to_phonemes("Hello World", espeakng::PhonemeGenOptions::Standard {
phoneme_mode: espeakng::PhonemeMode::default(),
text_mode: espeakng::TextMode::default(),
})?.unwrap();
println!("Phonemes: {}", phonemes);
Ok(())
}
Re-exports
pub use espeakng_sys as bindings;
Structs
Enums
- An error from the
espeakNG
C library. - An error from this library.
- Type of character codes
Functions
- Gets the currently initialised Speaker. If not set, none is returned.
- Initialise the internal espeak-ng library. If already initialised, that Speaker is returned.