g2pM
This is the official repository of our paper A Neural Grapheme-to-Phoneme Conversion Package for MandarinChinese Based on a New Open Benchmark Dataset (Interspeech 2020).
Install
pip install g2pM
The CPP Dataset
In data folder, there are [train/dev/test].sent files and [train/dev/test].lb files. In *.sent file, each lines corresponds to one sentence and a special symbol ▁ (U+2581) is added to the left and right of polyphonic character. The pronunciation of the corresponding character is at the same line from *.lb file. For each sentence, there could be several polyphonic characters, but we randomly choose only one polyphonic character to annotate.
Requirements
- python >= 3.6
- numpy
Usage
If you want to remove all the digits which denote the tones, set tone=False. Default setting is tone=True.
If you want to split all the non Chinese characters (e.g. digit), set char_split=True. Default setting is char_split=False.
>>> from g2pM import G2pM
>>> model = G2pM()
>>> sentence = "然而,他红了20年以后,他竟退出了大家的视线。"
>>> model(sentence, tone=True, char_split=False)
['ran2', 'er2', ',', 'ta1', 'hong2', 'le5', '20', 'nian2', 'yi3', 'hou4', ',', 'ta1', 'jing4', 'tui4', 'chu1', 'le5', 'da4', 'jia1', 'de5', 'shi4', 'xian4', '。']
>>> model(sentence, tone=False, char_split=False)
['ran', 'er', ',', 'ta', 'hong', 'le', '2', '0', 'nian', 'yi', 'hou', ',', 'ta', 'jing', 'tui', 'chu', 'le', 'da', 'jia', 'de', 'shi', 'xian', '。']
>>> model(sentence, tone=True, char_split=True)
['ran2', 'er2', ',', 'ta1', 'hong2', 'le5', '2', '0', 'nian2', 'yi3', 'hou4', ',', 'ta1', 'jing4', 'tui4', 'chu1', 'le5', 'da4', 'jia1', 'de5', 'shi4', 'xian4', '。']
Model Size
| Layer | Size |
|---|---|
| Embedding | 64 |
| LSTM x1 | 64 |
| Fully-Connected x2 | 64 |
| Total # of parameters | 477,228 |
| Model size | 1.7MB |
| Package size | 2.1MB |
Evaluation Result
| Model | Dev. | Test |
|---|---|---|
| g2pC | 84.84 | 84.45 |
| xpinyin(0.5.6) | 78.74 | 78.56 |
| pypinyin(0.36.0) | 85.44 | 86.13 |
| Majority Vote | 92.15 | 92.08 |
| Chinese Bert | 97.95 | 97.85 |
| Ours | 97.36 | 97.31 |
Reference
To cite the code/data/paper, please use this BibTex
@article{park2020g2pm,
author={Park, Kyubyong and Lee, Seanie},
title = {A Neural Grapheme-to-Phoneme Conversion Package for MandarinChinese Based on a New Open Benchmark Dataset
},
journal={Proc. Interspeech 2020},
url = {https://arxiv.org/abs/2004.03136},
year = {2020}
}
Metadata
Release files for g2pM 0.1.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| g2pM-0.1.2.5.tar.gz | 1.7 MB | Without provenance | Details for g2pM-0.1.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| g2pM-0.1.2.5-py3-none-any.whl | Python 3 | none | any | Details for g2pM-0.1.2.5-py3-none-any.whl |
Total release size: 3.3 MB
Release files / g2pM-0.1.2.5.tar.gz
| Download URL | g2pM-0.1.2.5.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd1ccdb1cd512dfe6ece51578d4210c154e59d02a5f99fb215ab6c04ff387483
|
|
BLAKE2b-256 checksum How to use checksums |
2ed606b20ffa5ea2e2a6c55ada6bf9503c1ee7bae2c64b3f6aa6107396a0a657
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Release files / g2pM-0.1.2.5-py3-none-any.whl
| Download URL | g2pM-0.1.2.5-py3-none-any.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e920b82df4002f96d8679720c7a858d10816d438dbd61b8b6b621a80a976361
|
|
BLAKE2b-256 checksum How to use checksums |
af21dc5b497f09a94a9605e0b8a94ad0e01ae73a2b65109bf5bd325b0814b6a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Security for g2pM 0.1.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.