g2pM: A Neural Grapheme-to-Phoneme Conversion Package for MandarinChinese Based on a New Open Benchmark Dataset

Kyubyong Park, Seanie Lee

Abstract

Mandarin Chinese Grapheme-to-Phoneme (G2P) conversion is a critical component for Text-to-Speech (TTS) systems, yet it remains challenging due to polyphonic characters. We present g2pM, a lightweight Python package for Mandarin G2P, and the Chinese Polyphones with Pinyin (CPP) dataset—the first large-scale, open-source benchmark for this task. Our results show that a compact Bi-LSTM model achieves 97.31% accuracy, rivaling massive transformer models like BERT while maintaining a minimal computational footprint.

Introduction

Grapheme-to-Phoneme (G2P) conversion in Mandarin Chinese involves mapping characters to their corresponding Pinyin. This task is significantly complicated by polyphones: characters with multiple pronunciations determined by context. For example, the character '的' is typically pronounced de, but in the word '目的' (purpose), it is pronounced dì.

Despite its importance, the field suffers from two major issues:

  1. Data Scarcity: Existing research often relies on proprietary datasets, hindering reproducible benchmarks.
  2. Accessibility: State-of-the-art models are rarely released as easy-to-use software, forcing developers to rely on less accurate rule-based tools.

The CPP Dataset

A primary contribution of this work is the Chinese Polyphones with Pinyin (CPP) dataset. Extracted from Chinese Wikipedia and human-annotated for high quality, it targets 623 unique polyphonic characters across nearly 100,000 sentences.

Statistics of the CPP dataset across training, development, and test sets.

Analysis of the corpus reveals that while polyphones make up only 4.3% of unique characters, they appear in 18.49% of all character instances, underscoring their impact on TTS quality. Unlike previous datasets derived from news sources like People's Daily, CPP is freely available for research.

Methodology

We frame polyphone disambiguation as a sequence classification problem. The g2pM model utilizes a Bi-LSTM Encoder to capture bidirectional context without the need for complex linguistic preprocessing like word segmentation or Part-of-Speech tagging.

Architecture of the g2pM model using a Bi-LSTM encoder for polyphone disambiguation.

The model maps characters to 64-dimensional embeddings, processes them through a Bi-LSTM, and uses the hidden state $\mathbf{h}_j$ of the target polyphone to predict the Pinyin distribution via a Softmax layer. The final package is implemented in NumPy to minimize dependencies and ensure it is lightweight enough for production environments.

Results and Discussion

The g2pM model was evaluated against common open-source libraries and a fine-tuned Chinese BERT model. While a "majority vote" baseline (always picking the most common pronunciation) reaches 92.08%, the remaining ~8% contains the most difficult context-dependent cases where TTS systems usually fail.

System Test Accuracy
xpinyin 78.56%
pypinyin 86.13%
Majority Vote (Baseline) 92.08%
g2pM (Ours) 97.31%
Chinese BERT 97.85%

Our model significantly outperforms existing rule-based systems. Notably, it achieves performance comparable to BERT (97.85%) despite having only 477k parameters (1.7MB) compared to BERT's 102M+ parameters. This efficiency makes g2pM ideal for real-time production TTS environments.

Conclusion

The g2pM package and CPP dataset provide a new standard for Mandarin G2P conversion. By combining a lightweight neural architecture with a large-scale open dataset, we bridge the gap between research and practical application. Future work will focus on expanding support for traditional Chinese and exploring sequence-to-sequence models for out-of-vocabulary characters.

Reference: Code and dataset are available at github.com/kakaobrain/g2pM.

Summary updated

BibTeX
@inproceedings{park2020g,
  author = {Kyubyong Park and Seanie Lee},
  title = {{g2pM: A Neural Grapheme-to-Phoneme Conversion Package for MandarinChinese Based on a New Open Benchmark Dataset}},
  booktitle = {Interspeech},
  year = {2020},
  doi = {10.21437/interspeech.2020-1094},
}
Figure