Search for "Text Normalization"(TN) on Google and Github, you can hardly find open-source projects that are "read-to-use" for text normalization tasks. Instead, you find a bunch of NLP toolkits or frameworks that supports TN functionality. There is quite some work between "support text normalization" and "do text normalization".
-
TN is language-dependent, more or less.
Some of TN processing methods are shared across languages, but a good TN module always involves language-specific knowledge and treatments, more or less.
-
TN is task-specific.
Even for the same language, different applications require quite different TN.
-
TN is "dirty"
Constructing and maintaining a set of TN rewrite-rules is painful, whatever toolkits and frameworks you choose. Subtle and intrinsic complexities hide inside TN task itself, not in tools or frameworks.
-
mature TN module is an asset
Since constructing and maintaining TN is hard, it is actually an asset for commercial companies, hence it is unlikely to find a product-level TN in open-source community (correct me if you find any)
-
TN is a less important topic for either academic or commercials.
This project sets up a ready-to-use TN module for Chinese. Since my background is speech processing, this project should be able to handle most common TN tasks, in Chinese ASR text processing pipelines.
-
supported NSW (Non-Standard-Word) Normalization
acknowledgement: the NSW normalization codes are based on Zhiyang Zhou's work here
-
punctuation removal
For Chinese, it removes punctuation list collected in Zhon project, containing
- non-stop puncs
'"#$%&'()*+,-/:;<=>@[\]^_`{|}~⦅⦆「」、、〃》「」『』【】〔〕〖〗〘〙〚〛〜〝〞〟〰〾〿–—‘’‛“”„‟…‧﹏' - stop puncs
'!?。。'
For English, it removes Python's
string.punctuation - non-stop puncs
-
multilingual English word upper/lower case conversion since ASR/TTS lexicons usually unify English entries to uppercase or lowercase, the TN module should adapt with lexicon accordingly.
-
plain text, one sentence per line(.txt)
今天早饭吃了没 没吃回家吃去吧 ...plain text is default format.
-
Kaldi's archive format(.ark)
KALDI_KEY_UTT001 今天早饭吃了没 KALDI_KEY_UTT002 没吃回家吃去吧 ...TN will skip first column key section, normalize latter transcription text
pass
--format arkoption to switch to kaldi ark format. -
table format(.tsv)
ID AUDIO TEXT UTT01 audio/UTT01.wav 今晚8点整中央5播出2020年总决赛 ...pass
--format tsvoption, normalization will apply toTEXTfield only.
note: All input text should be UTF-8 encoded.
- TN (python)
make sure you have python3, python2.X won't work correctly.
sh run.sh in TN dir, and compare raw text and normalized text.
- ITN (thrax)
make sure you have thrax installed, and your PATH should be able to find thrax binaries.
sh run.sh in ITN dir. check Makefile for grammar dependency.
Since TN is a typical "done is better than perfect" module in context of ASR, and the current state is sufficient for my purpose, I probably won't update this repo frequently.
there are indeed something that needs to be improved:
-
For TN, NSW normalizers in TN dir are based on regular expression, I've found some unintended matches, those pattern regexps need to be refined for more precise TN coverage.
-
For ITN, extend those thrax rewriting grammars to cover more scenarios.
-
Further more, nowadays commercial systems start to introduce RNN-like models into TN, and a mix of (rule-based & model-based) system is state-of-the-art. More readings about this, look for Richard Sproat and KyleGorman's work at Google.
END
