Skip to content

Commit

Permalink
fix test data import to use module
Browse files Browse the repository at this point in the history
  • Loading branch information
aoirint committed Dec 4, 2021
1 parent c1b73a1 commit 7cb3088
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions test/data_hello_hiho.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from voicevox_engine.acoustic_feature_extractor import OjtPhoneme
from voicevox_engine.model import AccentPhrase, Mora

str_list_hello_hiho = "sil k o N n i ch i w a pau h i h o d e s U sil".split()
str_list = "sil k o N n i ch i w a pau h i h o d e s U sil".split()

phoneme_data_list_hello_hiho = [
phoneme_data_list = [
OjtPhoneme(phoneme=p, start=i, end=i + 1)
for i, p in enumerate("pau k o N n i ch i w a pau h i h o d e s U pau".split())
]

accent_phrases_hello_hiho = [
accent_phrases = [
AccentPhrase(
moras=[
Mora(
Expand Down
6 changes: 3 additions & 3 deletions test/synthesis_engine/mora/test_pre_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
from voicevox_engine.acoustic_feature_extractor import OjtPhoneme
from voicevox_engine.synthesis_engine.mora import pre_process

from ...data_hello_hiho import accent_phrases_hello_hiho
from ... import data_hello_hiho


class TestPreProcess(TestCase):
def test_pre_process(self):
flatten_moras, phoneme_data_list = pre_process(
deepcopy(accent_phrases_hello_hiho)
deepcopy(data_hello_hiho.accent_phrases)
)

mora_index = 0
phoneme_index = 1

self.assertEqual(phoneme_data_list[0], OjtPhoneme("pau", 0, 1))
for accent_phrase in accent_phrases_hello_hiho:
for accent_phrase in data_hello_hiho.accent_phrases:
moras = accent_phrase.moras
for mora in moras:
self.assertEqual(flatten_moras[mora_index], mora)
Expand Down
4 changes: 2 additions & 2 deletions test/synthesis_engine/mora/test_split_mora.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from voicevox_engine.acoustic_feature_extractor import OjtPhoneme
from voicevox_engine.synthesis_engine.mora import split_mora

from ...data_hello_hiho import phoneme_data_list_hello_hiho
from ... import data_hello_hiho


class TestSplitMora(TestCase):
def test_split_mora(self):
consonant_phoneme_list, vowel_phoneme_list, vowel_indexes = split_mora(
phoneme_data_list_hello_hiho
data_hello_hiho.phoneme_data_list
)

self.assertEqual(vowel_indexes, [0, 2, 3, 5, 7, 9, 10, 12, 14, 16, 18, 19])
Expand Down
10 changes: 5 additions & 5 deletions test/synthesis_engine/mora/test_to_flatten_moras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from voicevox_engine.synthesis_engine.mora import to_flatten_moras

from ...data_hello_hiho import accent_phrases_hello_hiho
from ... import data_hello_hiho


class TestToFlattenMoras(TestCase):
def test_to_flatten_moras(self):
flatten_moras = to_flatten_moras(accent_phrases_hello_hiho)
flatten_moras = to_flatten_moras(data_hello_hiho.accent_phrases)
self.assertEqual(
flatten_moras,
accent_phrases_hello_hiho[0].moras
+ [accent_phrases_hello_hiho[0].pause_mora]
+ accent_phrases_hello_hiho[1].moras,
data_hello_hiho.accent_phrases[0].moras
+ [data_hello_hiho.accent_phrases[0].pause_mora]
+ data_hello_hiho.accent_phrases[1].moras,
)
6 changes: 3 additions & 3 deletions test/synthesis_engine/mora/test_to_phoneme_data_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from voicevox_engine.synthesis_engine.mora import to_phoneme_data_list

from ...data_hello_hiho import phoneme_data_list_hello_hiho, str_list_hello_hiho
from ... import data_hello_hiho


class TestToPhonemeDataList(TestCase):
def test_to_phoneme_data_list(self):
phoneme_data_list = to_phoneme_data_list(str_list_hello_hiho)
self.assertEqual(phoneme_data_list, phoneme_data_list_hello_hiho)
phoneme_data_list = to_phoneme_data_list(data_hello_hiho.str_list)
self.assertEqual(phoneme_data_list, data_hello_hiho.phoneme_data_list)
12 changes: 6 additions & 6 deletions test/synthesis_engine/test_synthesis_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from voicevox_engine.synthesis_engine import SynthesisEngine
from voicevox_engine.synthesis_engine.mora import unvoiced_mora_phoneme_list

from ..data_hello_hiho import accent_phrases_hello_hiho
from .. import data_hello_hiho


def yukarin_s_mock(length: int, phoneme_list: numpy.ndarray, speaker_id: numpy.ndarray):
Expand Down Expand Up @@ -89,7 +89,7 @@ def setUp(self):

def test_replace_phoneme_length(self):
result = self.synthesis_engine.replace_phoneme_length(
accent_phrases=deepcopy(accent_phrases_hello_hiho), speaker_id=1
accent_phrases=deepcopy(data_hello_hiho.accent_phrases), speaker_id=1
)

# yukarin_sに渡される値の検証
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_replace_phoneme_length(self):
self.assertEqual(yukarin_s_args["speaker_id"], 1)

# flatten_morasを使わずに愚直にaccent_phrasesにデータを反映させてみる
true_result = deepcopy(accent_phrases_hello_hiho)
true_result = deepcopy(data_hello_hiho.accent_phrases)
index = 1

def result_value(i: int):
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_replace_mora_pitch(self):
)

result = self.synthesis_engine.replace_mora_pitch(
accent_phrases=deepcopy(accent_phrases_hello_hiho), speaker_id=1
accent_phrases=deepcopy(data_hello_hiho.accent_phrases), speaker_id=1
)

# yukarin_saに渡される値の検証
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_replace_mora_pitch(self):
)

# flatten_morasを使わずに愚直にaccent_phrasesにデータを反映させてみる
true_result = deepcopy(accent_phrases_hello_hiho)
true_result = deepcopy(data_hello_hiho.accent_phrases)
index = 1

def result_value(i: int):
Expand Down Expand Up @@ -388,7 +388,7 @@ def synthesis_test_base(self, audio_query: AudioQuery):

def test_synthesis(self):
audio_query = AudioQuery(
accent_phrases=deepcopy(accent_phrases_hello_hiho),
accent_phrases=deepcopy(data_hello_hiho.accent_phrases),
speedScale=1.0,
pitchScale=1.0,
intonationScale=1.0,
Expand Down

0 comments on commit 7cb3088

Please sign in to comment.