About this project

Haqumei (薄明/拍命) is a Japanese Grapheme-to-Phoneme (G2P) library implemented in Rust, with Python bindings and a command-line interface. It converts Japanese text into phoneme sequences, providing accurate and detailed linguistic analysis for speech synthesis and text-to-speech frontends. **Core Capabilities** The library provides several key APIs: - `g2p`: Basic text-to-phoneme conversion - `g2k`: Text-to-katakana reading conversion - `g2p_prosody`: Phoneme sequences annotated with prosodic symbols (pitch rise/fall, phrase boundaries, pauses) - `g2p_mapping`: Word-phoneme mapping with unknown word detection - `g2p_mapping_detailed`: Detailed mapping including part-of-speech and accent information - `g2p_mapping_prosody`: Structured mapping with prosody, pitch, and morphological information - `g2p_candidates`: Multiple reading candidates for ambiguous text **Accuracy** Haqumei achieves 0.83% phoneme error rate (PER) on the jsut-label benchmark and 0.78% katakana error rate (KER) on ROHAN, outperforming pyopenjtalk (1.31% PER, 5.02% KER) and pyopenjtalk-plus (1.09% PER, 1.60% KER). The accuracy improvements build on the dictionary and techniques from pyopenjtalk-plus. **Features** - **Word-Phoneme Mapping**: Provides mapping between words and phonemes, including detection of unknown words (`unk`) and spaces (`sp`), enabling minimal information loss from input text. - **Prosody Information**: Supports multiple prosody formats (Default, Prefix, Numeric) with pitch high/low annotations, accent phrase boundaries, and prosodic symbols. - **Allophone Resolution**: Handles moraic nasals (撥音) and geminate consonants (促音) with dedicated phoneme labels. - **Unknown Word Fallbacks**: Reading estimation for English words via haqumei-kanalizer, on'yomi fallback for kanji, and accent correction for katakana-only words. - **Concurrency**: Batch processing methods for multi-threaded G2P operations. - **Custom Options**: Flexible configuration for allophone labels, Unicode normalization, and reading behavior. - **Custom Dictionaries**: Support for building with custom embedded dictionaries. **Installation** - Rust: `cargo add haqumei` - Python: `pip install haqumei` (pre-built wheels for Linux x86_64/aarch64, macOS aarch64, Windows x86_64) - CLI: `cargo install haqumei-cli` **Technical Details** The library uses MeCab for morphological analysis and extends the HTS-format full-context label format. It embeds a dictionary during the build process (downloaded from the network unless a custom dictionary is provided). The Python bindings use pre-built wheels that bundle the dictionary, requiring no network access during installation. **License** Apache-2.0