Shadhil's picture
voice-clone with single audio sample input
9b2107c
from typing import Dict
from TTS.tts.utils.text.korean.phonemizer import korean_text_to_phonemes
from TTS.tts.utils.text.phonemizers.base import BasePhonemizer
_DEF_KO_PUNCS = "ใ€.,[]()?!ใ€ฝ~ใ€Žใ€ใ€Œใ€ใ€ใ€‘"
class KO_KR_Phonemizer(BasePhonemizer):
"""๐ŸธTTS ko_kr_phonemizer using functions in `TTS.tts.utils.text.korean.phonemizer`
TODO: Add Korean to character (แ„€แ„แ„‚แ„ƒแ„„แ„…แ„†แ„‡แ„ˆแ„‰แ„Šแ„‹แ„Œแ„แ„Žแ„แ„แ„‘แ„’แ…กแ…ขแ…ฃแ…คแ…ฅแ…ฆแ…งแ…จแ…ฉแ…ชแ…ซแ…ฌแ…ญแ…ฎแ…ฏแ…ฐแ…ฑแ…ฒแ…ณแ…ดแ…ตแ†จแ†ฉแ†ชแ†ซแ†ฌแ†ญแ†ฎแ†ฏแ†ฐแ†ฑแ†ฒแ†ณแ†ดแ†ตแ†ถแ†ทแ†ธแ†นแ†บแ†ปแ†ผแ†ฝแ†พแ†ฟแ‡€แ‡แ‡‚)
Example:
>>> from TTS.tts.utils.text.phonemizers import KO_KR_Phonemizer
>>> phonemizer = KO_KR_Phonemizer()
>>> phonemizer.phonemize("์ด ๋ฌธ์žฅ์€ ์Œ์„ฑํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋ฌธ์žฅ์ž…๋‹ˆ๋‹ค.", separator="|")
'แ„‹|แ…ต| |แ„†|แ…ฎ|แ†ซ|แ„Œ|แ…ก|แ†ผ|แ„‹|แ…ณ| |แ„‚|แ…ณ|แ†ท|แ„‰|แ…ฅ|แ†ผ|แ„’|แ…ก|แ†ธ|แ„Š|แ…ฅ|แ†ผ| |แ„|แ…ฆ|แ„‰|แ…ณ|แ„|แ…ณ|แ„…|แ…ณ| |แ„…|แ…ฑ|แ„’|แ…ก|แ†ซ| |แ„†|แ…ฎ|แ†ซ|แ„Œ|แ…ก|แ†ผ|แ„‹|แ…ต|แ†ท|แ„‚|แ…ต|แ„ƒ|แ…ก|.'
>>> from TTS.tts.utils.text.phonemizers import KO_KR_Phonemizer
>>> phonemizer = KO_KR_Phonemizer()
>>> phonemizer.phonemize("์ด ๋ฌธ์žฅ์€ ์Œ์„ฑํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋ฌธ์žฅ์ž…๋‹ˆ๋‹ค.", separator="|", character='english')
'I| |M|u|n|J|a|n|g|E|u| |N|e|u|m|S|e|o|n|g|H|a|b|S|s|e|o|n|g| |T|e|S|e|u|T|e|u|L|e|u| |L|w|i|H|a|n| |M|u|n|J|a|n|g|I|m|N|i|D|a|.'
"""
language = "ko-kr"
def __init__(self, punctuations=_DEF_KO_PUNCS, keep_puncs=True, **kwargs): # pylint: disable=unused-argument
super().__init__(self.language, punctuations=punctuations, keep_puncs=keep_puncs)
@staticmethod
def name():
return "ko_kr_phonemizer"
def _phonemize(self, text: str, separator: str = "", character: str = "hangeul") -> str:
ph = korean_text_to_phonemes(text, character=character)
if separator is not None or separator != "":
return separator.join(ph)
return ph
def phonemize(self, text: str, separator: str = "", character: str = "hangeul", language=None) -> str:
return self._phonemize(text, separator, character)
@staticmethod
def supported_languages() -> Dict:
return {"ko-kr": "hangeul(korean)"}
def version(self) -> str:
return "0.0.2"
def is_available(self) -> bool:
return True
if __name__ == "__main__":
texts = "์ด ๋ฌธ์žฅ์€ ์Œ์„ฑํ•ฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋ฌธ์žฅ์ž…๋‹ˆ๋‹ค."
e = KO_KR_Phonemizer()
print(e.supported_languages())
print(e.version())
print(e.language)
print(e.name())
print(e.is_available())
print(e.phonemize(texts))