File size: 1,581 Bytes
45ee559
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest

from TTS.tts.utils.text.korean.phonemizer import korean_text_to_phonemes

_TEST_CASES = """
ํฌ์ƒ์€ ์—ด์‹ฌํžˆ ํ•œ ์•„์ด์—๊ฒŒ๋งŒ ์ฃผ์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ํฌ์ƒ์ธ ๊ฒƒ์ž…๋‹ˆ๋‹ค./แ„‘แ…ฉแ„‰แ…กแ†ผแ„‹แ…ณ แ„‚แ…งแ†ฏแ„‰แ…ตแ†ทแ„’แ…ต แ„’แ…ก แ„‚แ…กแ„‹แ…ตแ„‹แ…ฆแ„€แ…ฆแ„†แ…กแ†ซ แ„Œแ…ฎแ„‹แ…ฅแ„Œแ…ตแ„€แ…ต แ„„แ…ขแ„†แ…ฎแ„‚แ…ฆ แ„‘แ…ฉแ„‰แ…กแ†ผแ„‹แ…ตแ†ซ แ„€แ…ฅแ„‰แ…ตแ†ทแ„‚แ…ตแ„ƒแ…ก.
์˜ค๋Š˜์€ 8์›” 31์ผ ์ž…๋‹ˆ๋‹ค./แ„‹แ…ฉแ„‚แ…ณแ„…แ…ณแ†ซ แ„‘แ…กแ„…แ…ฏแ†ฏ แ„‰แ…กแ†ทแ„‰แ…ตแ„‡แ…ตแ„…แ…ต แ„…แ…ตแ†ทแ„‚แ…ตแ„ƒแ…ก.
์นœ๊ตฌ 100๋ช… ๋งŒ๋“ค๊ธฐ๊ฐ€ ๋ชฉํ‘œ์ž…๋‹ˆ๋‹ค./แ„Žแ…ตแ†ซแ„€แ…ฎ แ„‡แ…ขแ†ผแ„†แ…งแ†ผ แ„†แ…กแ†ซแ„ƒแ…ณแ†ฏแ„€แ…ตแ„€แ…ก แ„†แ…ฉแ†จแ„‘แ…ญแ„‹แ…ตแ†ทแ„‚แ…ตแ„ƒแ…ก.
A๋ถ€ํ„ฐ Z๊นŒ์ง€ ์ž…๋‹ˆ๋‹ค./แ„‹แ…ฆแ„‹แ…ตแ„‡แ…ฎแ„แ…ฅ แ„Œแ…ฆแ„แ…ณแ„แ…กแ„Œแ…ต แ„‹แ…ตแ†ทแ„‚แ…ตแ„ƒแ…ก.
์ด๊ฒŒ ์ œ ๋งˆ์Œ์ด์—์š”./แ„‹แ…ตแ„€แ…ฆ แ„Œแ…ฆ แ„†แ…กแ„‹แ…ณแ„†แ…ตแ„‹แ…ฆแ„‹แ…ญ.
"""
_TEST_CASES_EN = """
์ด์ œ์•ผ ์ด์ชฝ์„ ๋ณด๋Š”๊ตฌ๋‚˜./IJeYa IJjoGeul BoNeunGuNa.
ํฌ๊ณ  ๋ง›์žˆ๋Š” cake๋ฅผ ๋ถ€ํƒํ•ด์š”./KeuGo MaSinNeun KeIKeuLeul BuTaKaeYo.
์ „๋ถ€ ๊ฑฐ์ง“๋ง์ด์•ผ./JeonBu GeoJinMaLiYa.
์ข‹์€ ๋…ธ๋ž˜๋ฅผ ์ฐพ์•˜์–ด์š”./JoEun NoLaeLeul ChaJaSseoYo.
"""


class TestText(unittest.TestCase):
    def test_korean_text_to_phonemes(self):
        for line in _TEST_CASES.strip().split("\n"):
            text, phone = line.split("/")
            self.assertEqual(korean_text_to_phonemes(text), phone)
        for line in _TEST_CASES_EN.strip().split("\n"):
            text, phone = line.split("/")
            self.assertEqual(korean_text_to_phonemes(text, character="english"), phone)


if __name__ == "__main__":
    unittest.main()