mirror of https://github.com/coqui-ai/TTS.git
fix: make chinese g2p deps optional
This commit is contained in:
parent
ea893c3795
commit
55ed162f2a
|
@ -159,9 +159,10 @@ The following extras allow the installation of optional dependencies:
|
|||
| `server` | Dependencies to run the TTS server |
|
||||
| `bn` | Bangla G2P |
|
||||
| `ja` | Japanese G2P |
|
||||
| `zh` | Chinese G2P |
|
||||
| `languages` | All language-specific dependencies |
|
||||
|
||||
You can install them with one of the following commands:
|
||||
You can install extras with one of the following commands:
|
||||
|
||||
```bash
|
||||
pip install coqui-tts[server,ja]
|
||||
|
|
|
@ -4,7 +4,6 @@ import re
|
|||
import textwrap
|
||||
from functools import cached_property
|
||||
|
||||
import pypinyin
|
||||
import torch
|
||||
from hangul_romanize import Transliter
|
||||
from hangul_romanize.rule import academic
|
||||
|
@ -577,6 +576,10 @@ def basic_cleaners(text):
|
|||
|
||||
|
||||
def chinese_transliterate(text):
|
||||
try:
|
||||
import pypinyin
|
||||
except ImportError as e:
|
||||
raise ImportError("Chinese requires: pypinyin") from e
|
||||
return "".join(
|
||||
[p[0] for p in pypinyin.pinyin(text, style=pypinyin.Style.TONE3, heteronym=False, neutral_tone_with_five=True)]
|
||||
)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
from typing import List
|
||||
|
||||
import jieba
|
||||
import pypinyin
|
||||
try:
|
||||
import jieba
|
||||
import pypinyin
|
||||
except ImportError as e:
|
||||
raise ImportError("Chinese requires: jieba, pypinyin") from e
|
||||
|
||||
from .pinyinToPhonemes import PINYIN_DICT
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from TTS.tts.utils.text.phonemizers.belarusian_phonemizer import BEL_Phonemizer
|
|||
from TTS.tts.utils.text.phonemizers.espeak_wrapper import ESpeak
|
||||
from TTS.tts.utils.text.phonemizers.gruut_wrapper import Gruut
|
||||
from TTS.tts.utils.text.phonemizers.ko_kr_phonemizer import KO_KR_Phonemizer
|
||||
from TTS.tts.utils.text.phonemizers.zh_cn_phonemizer import ZH_CN_Phonemizer
|
||||
|
||||
try:
|
||||
from TTS.tts.utils.text.phonemizers.bangla_phonemizer import BN_Phonemizer
|
||||
|
@ -15,6 +14,11 @@ try:
|
|||
except ImportError:
|
||||
JA_JP_Phonemizer = None
|
||||
|
||||
try:
|
||||
from TTS.tts.utils.text.phonemizers.zh_cn_phonemizer import ZH_CN_Phonemizer
|
||||
except ImportError:
|
||||
ZH_CN_Phonemizer = None
|
||||
|
||||
PHONEMIZERS = {b.name(): b for b in (ESpeak, Gruut, KO_KR_Phonemizer)}
|
||||
|
||||
|
||||
|
@ -36,7 +40,6 @@ DEF_LANG_TO_PHONEMIZER.update(_new_dict)
|
|||
|
||||
# Force default for some languages
|
||||
DEF_LANG_TO_PHONEMIZER["en"] = DEF_LANG_TO_PHONEMIZER["en-us"]
|
||||
DEF_LANG_TO_PHONEMIZER["zh-cn"] = ZH_CN_Phonemizer.name()
|
||||
DEF_LANG_TO_PHONEMIZER["ko-kr"] = KO_KR_Phonemizer.name()
|
||||
DEF_LANG_TO_PHONEMIZER["be"] = BEL_Phonemizer.name()
|
||||
|
||||
|
@ -47,6 +50,9 @@ if BN_Phonemizer is not None:
|
|||
if JA_JP_Phonemizer is not None:
|
||||
PHONEMIZERS[JA_JP_Phonemizer.name()] = JA_JP_Phonemizer
|
||||
DEF_LANG_TO_PHONEMIZER["ja-jp"] = JA_JP_Phonemizer.name()
|
||||
if ZH_CN_Phonemizer is not None:
|
||||
PHONEMIZERS[ZH_CN_Phonemizer.name()] = ZH_CN_Phonemizer
|
||||
DEF_LANG_TO_PHONEMIZER["zh-cn"] = ZH_CN_Phonemizer.name()
|
||||
|
||||
|
||||
def get_phonemizer_by_name(name: str, **kwargs) -> BasePhonemizer:
|
||||
|
@ -64,6 +70,8 @@ def get_phonemizer_by_name(name: str, **kwargs) -> BasePhonemizer:
|
|||
if name == "gruut":
|
||||
return Gruut(**kwargs)
|
||||
if name == "zh_cn_phonemizer":
|
||||
if ZH_CN_Phonemizer is None:
|
||||
raise ValueError("You need to install ZH phonemizer dependencies. Try `pip install coqui-tts[zh]`.")
|
||||
return ZH_CN_Phonemizer(**kwargs)
|
||||
if name == "ja_jp_phonemizer":
|
||||
if JA_JP_Phonemizer is None:
|
||||
|
|
|
@ -65,9 +65,6 @@ dependencies = [
|
|||
# Coqui stack
|
||||
"coqui-tts-trainer>=0.1",
|
||||
"coqpit>=0.0.16",
|
||||
# Chinese
|
||||
"jieba",
|
||||
"pypinyin",
|
||||
# Korean
|
||||
"hangul_romanize",
|
||||
"jamo",
|
||||
|
@ -123,13 +120,18 @@ ja = [
|
|||
"unidic-lite==1.0.8",
|
||||
"cutlet",
|
||||
]
|
||||
# Chinese
|
||||
zh = [
|
||||
"jieba",
|
||||
"pypinyin",
|
||||
]
|
||||
# All language-specific dependencies
|
||||
languages = [
|
||||
"coqui-tts[bn,ja]",
|
||||
"coqui-tts[bn,ja,zh]",
|
||||
]
|
||||
# Installs all extras (except dev and docs)
|
||||
all = [
|
||||
"coqui-tts[notebooks,server,bn,ja]",
|
||||
"coqui-tts[notebooks,server,bn,ja,zh]",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
|
Loading…
Reference in New Issue