Crate espeakng

Source
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

§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§

Language
PhonemeMode
Speaker
Voice

Enums§

ESpeakNgError
An error from the espeakNG C library.
Error
An error from this library.
Gender
Parameter
PhonemeGenOptions
PunctationType
TextMode
Type of character codes

Functions§

get
Gets the currently initialised Speaker. If not set, none is returned.
initialise
Initialise the internal espeak-ng library. If already initialised, that Speaker is returned.

Type Aliases§

Result