File size: 1,194 Bytes
f1f433f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from unittest import TestCase

# TODO: import from voicevox_engine.synthesis_engine.mora
from voicevox_engine.synthesis_engine.synthesis_engine_base import mora_to_text


class TestMoraToText(TestCase):
    def test_voice(self):
        self.assertEqual(mora_to_text("a"), "ア")
        self.assertEqual(mora_to_text("i"), "イ")
        self.assertEqual(mora_to_text("ka"), "カ")
        self.assertEqual(mora_to_text("N"), "ン")
        self.assertEqual(mora_to_text("cl"), "ッ")
        self.assertEqual(mora_to_text("gye"), "ギェ")
        self.assertEqual(mora_to_text("ye"), "イェ")
        self.assertEqual(mora_to_text("wo"), "ウォ")

    def test_unvoice(self):
        self.assertEqual(mora_to_text("A"), "ア")
        self.assertEqual(mora_to_text("I"), "イ")
        self.assertEqual(mora_to_text("kA"), "カ")
        self.assertEqual(mora_to_text("gyE"), "ギェ")
        self.assertEqual(mora_to_text("yE"), "イェ")
        self.assertEqual(mora_to_text("wO"), "ウォ")

    def test_invalid_mora(self):
        """変なモーラが来ても例外を投げない"""
        self.assertEqual(mora_to_text("x"), "x")
        self.assertEqual(mora_to_text(""), "")