#ng #speaker #voice #phoneme #text #default #espeak-ng-sys

espeakng

A safe Rust wrapper around espeakNG via espeakNG-sys

4 releases

0.2.0 Aug 6, 2023
0.1.2 Aug 5, 2023
0.1.1 Feb 26, 2022
0.1.0 Feb 19, 2022

#819 in Audio

MIT license

26KB
489 lines

espeakNG-rs

A safe Rust wrapper around espeak NG via espeakNG-sys.

Once installed, read the documentation with cargo doc --open -p espeakng.


lib.rs:

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

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(())
}

Dependencies

~2–10MB
~120K SLoC