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


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

#731 in Audio

MIT license

489 lines


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

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


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


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


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(),
    println!("Phonemes: {}", phonemes);



~123K SLoC