phonetisaurus-g2p

Crates.iophonetisaurus-g2p
lib.rsphonetisaurus-g2p
version0.1.1
created_at2025-04-08 22:02:20.964335+00
updated_at2025-04-08 22:12:55.953676+00
descriptionPhonemization in Rust using a finite state transducer (FST) trained with Phonetisaurus.
homepage
repositoryhttps://github.com/lastleon/phonetisaurus-g2p-rs
max_upload_size
id1626022
size23,547
Leon T. (lastleon)

documentation

README

Phonetisaurus-G2P

Phonemization in Rust using a finite state transducer (FST) trained with Phonetisaurus.

Allows easy usage of a Phonetisaurus-trained FST for grapheme-to-phoneme conversion. Based on rustfst, a Rust implementation of FSTs compatible with OpenFST models, and thus also with Phonetisaurus. In theory, this library can be used with all OpenFST models, but only Phonetisaurus was tested and some details might only be applicable for Phonetisaurus.

Note that the API might slightly change in the future.

Usage

To use the crate, add the following to your Cargo.toml:

[dependencies]
phonetisaurus-g2p = "0.1.1"

Then, you can include the model file in your binary and run it:

use phonetisaurus_g2p::PhonetisaurusModel;

static PHONETISAURUS_MODEL: &[u8] = include_bytes!("model.fst");

fn main() {
    let phonemizer = PhonetisaurusModel::try_from(PHONETISAURUS_MODEL).unwrap();

    let result = phonemizer.phonemize_word("world").unwrap();
    assert_eq!(result.phonemes, "wˈɜɹld")
}

Or load it from disk during runtime:

use phonetisaurus_g2p::PhonetisaurusModel;

fn main() {
    let phonemizer = PhonetisaurusModel::try_from(Path::new("model.fst")).unwrap();

    let result = phonemizer.phonemize_word("world").unwrap();
    assert_eq!(result.phonemes, "wˈɜɹld")
}

License

phonetisaurus-g2p-rs is licensed under the MIT License.

Commit count: 3

cargo fmt