Downloads · 30 days
0
NikiPshg/g2p_with_stress
g2p_with_stress is a machine learning model from NikiPshg. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This project provides a Grapheme to Phoneme (G2P) conversion tool that first checks the CMU Pronouncing Dictionary for phoneme translations. If a word is not found in the dictionary, it utilizes two Transformer-based…
Downloads · 30 days
0
Access
Public
Updated Nov 1, 2024
Repo size
225 MB
Likes
2
Public
Click a slice to open those files.
.pt248 MB · 98%
From the Hugging Face model README
This project provides a Grapheme to Phoneme (G2P) conversion tool that first checks the CMU Pronouncing Dictionary for phoneme translations. If a word is not found in the dictionary, it utilizes two Transformer-based models to generate phoneme translations and add stress markers. The output is in ARPAbet format, and the model can also convert graphemes into phoneme integer indices.
Clone the repository:
git clone https://github.com/NikiPshg/Grapheme-to-Phoneme-G2P-with-Stress.git
cd Grapheme-to-Phoneme-G2P-with-Stress
Install the required dependencies:
pip install -r requiremenst.txt
from G2P_lexicon import g2p_en_lexicon
# Initialize the G2P converter
g2p = g2p_en_lexicon()
# Convert a word to phonemes
text = "text, numbers, and some strange symbols !№;% 21"
phonemes = g2p(text, with_stress=False)
['T', 'EH', 'K', 'S', 'T', ' ', ',', ' ',
'N', 'AH', 'M', 'B', 'ER', 'Z',' ', ',', ' ',
'AE', 'N', 'D', ' ', 'S', 'AH', 'M', ' ',
'S', 'T', 'R', 'EY', 'N', 'JH',' ',
'S', 'IH', 'M', 'B', 'AH', 'L', 'Z',' ',
'T', 'W', 'EH', 'N', 'IY', ' ', 'W', 'AH', 'N']