mirror of https://github.com/coqui-ai/TTS.git
Fix ja_jp_phonemizer
This commit is contained in:
parent
20e5dd3678
commit
f0655bfffc
|
@ -5,30 +5,50 @@ from TTS.tts.utils.text.phonemizers.base import BasePhonemizer
|
||||||
|
|
||||||
_DEF_JA_PUNCS = "、.,[]()?!〽~『』「」【】"
|
_DEF_JA_PUNCS = "、.,[]()?!〽~『』「」【】"
|
||||||
|
|
||||||
|
_TRANS_TABLE = {"、": ","}
|
||||||
|
|
||||||
|
|
||||||
|
def trans(text):
|
||||||
|
for i, j in _TRANS_TABLE.items():
|
||||||
|
text = text.replace(i, j)
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
class JA_JP_Phonemizer(BasePhonemizer):
|
class JA_JP_Phonemizer(BasePhonemizer):
|
||||||
"""🐸TTS Ja-Jp phonemizer using functions in `TTS.tts.utils.text.japanese.phonemizer`
|
"""🐸TTS Ja-Jp phonemizer using functions in `TTS.tts.utils.text.japanese.phonemizer`
|
||||||
|
|
||||||
TODO: someone with JA knowledge should check this implementation
|
TODO: someone with JA knowledge should check this implementation
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
>>> from TTS.tts.utils.text.phonemizers import JA_JP_Phonemizer
|
||||||
|
>>> phonemizer = JA_JP_Phonemizer()
|
||||||
|
>>> phonemizer.phonemize("どちらに行きますか?", separator="|")
|
||||||
|
d|o|c|h|i|r|a|n|i|i|k|i|m|a|s|u|k|a|?
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
language = "ja-jp"
|
language = "ja-jp"
|
||||||
|
|
||||||
def __init__(self, punctuations=_DEF_JA_PUNCS, keep_puncs=False, **kwargs):
|
def __init__(self, punctuations=_DEF_JA_PUNCS, keep_puncs=True, **kwargs):
|
||||||
super().__init__(self.language, punctuations=punctuations, keep_puncs=keep_puncs)
|
super().__init__(self.language, punctuations=punctuations, keep_puncs=keep_puncs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "ja_jp_phonemizer"
|
return "ja_jp_phonemizer"
|
||||||
|
|
||||||
def phonemize_jajp(self, text: str, separator: str = "|") -> str:
|
def _phonemize(self, text: str, separator: str = "|") -> str:
|
||||||
ph = japanese_text_to_phonemes(text)
|
ph = japanese_text_to_phonemes(text)
|
||||||
if separator is not None or separator != "":
|
if separator is not None or separator != "":
|
||||||
return separator.join(ph)
|
return separator.join(ph)
|
||||||
return ph
|
return ph
|
||||||
|
|
||||||
def _phonemize(self, text, separator):
|
def phonemize(self, text: str, separator="|") -> str:
|
||||||
return self.phonemize_jajp(text, separator)
|
"""Custom phonemize for JP_JA
|
||||||
|
|
||||||
|
Skip pre-post processing steps used by the other phonemizers.
|
||||||
|
"""
|
||||||
|
return self._phonemize(text, separator)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def supported_languages() -> Dict:
|
def supported_languages() -> Dict:
|
||||||
|
|
Loading…
Reference in New Issue