Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine the multilingual front-end processing module #137

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/tts.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"task_type": "tts",
"preprocess": {
"language": "en-us",
"language": "en-us", // espeak supports 100 languages https://github.com/espeak-ng/espeak-ng/blob/master/docs/languages.md
// linguistic features
"extract_phone": true,
"phone_extractor": "espeak", // "espeak, pypinyin, pypinyin_initials_finals, lexicon (only for language=en-us right now)"
Expand Down
4 changes: 3 additions & 1 deletion processors/phone_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def __init__(self, cfg, dataset_name=None, phone_symbol_file=None):
"pypinyin",
"pypinyin_initials_finals",
]:
self.g2p_module = G2PModule(backend=cfg.preprocess.phone_extractor)
self.g2p_module = G2PModule(
backend=cfg.preprocess.phone_extractor, language=cfg.preprocess.language
)
elif cfg.preprocess.phone_extractor == "lexicon":
assert cfg.preprocess.lexicon_path != ""
self.g2p_module = LexiconModule(cfg.preprocess.lexicon_path)
Expand Down
7 changes: 7 additions & 0 deletions text/g2p_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def phonemize(
class G2PModule:
"""Phonemize Text."""

# We support espeak to extract IPA (International Phonetic Alphabet), which supports 100 languages,
# https://github.com/espeak-ng/espeak-ng/blob/master/docs/languages.md

def __init__(
self,
language="en-us",
Expand Down Expand Up @@ -144,6 +147,10 @@ def _initialize_backend(
words_mismatch=words_mismatch,
)
elif backend in ["pypinyin", "pypinyin_initials_finals"]:
if language != "cmn":
raise ValueError(
f"{language} is not supported for pypinyin and pypinyin_initials_finals."
)
return PypinyinBackend(
backend=backend,
punctuation_marks=punctuation_marks + self.separator.word,
Expand Down
Loading