From dc237e04689e52497b09301d17f8c616dec69a0a Mon Sep 17 00:00:00 2001 From: terepan Date: Thu, 4 Jan 2024 15:01:43 +0000 Subject: [PATCH] remove: `pre_process()` --- test/tts_pipeline/test_tts_engine.py | 37 ---------------------- voicevox_engine/tts_pipeline/tts_engine.py | 17 ++-------- 2 files changed, 3 insertions(+), 51 deletions(-) diff --git a/test/tts_pipeline/test_tts_engine.py b/test/tts_pipeline/test_tts_engine.py index 5dc7e7275..f4136b3c6 100644 --- a/test/tts_pipeline/test_tts_engine.py +++ b/test/tts_pipeline/test_tts_engine.py @@ -23,7 +23,6 @@ apply_speed_scale, apply_volume_scale, count_frame_per_unit, - pre_process, query_to_decoder_feature, raw_wave_to_output_wave, split_mora, @@ -530,42 +529,6 @@ def test_to_flatten_moras(self): + true_accent_phrases_hello_hiho[1].moras, ) - def test_pre_process(self): - flatten_moras, phoneme_data_list = pre_process(_gen_hello_hiho_accent_phrases()) - - mora_index = 0 - phoneme_index = 1 - - self.assertTrue(is_same_phoneme(phoneme_data_list[0], Phoneme("pau"))) - for accent_phrase in _gen_hello_hiho_accent_phrases(): - moras = accent_phrase.moras - for mora in moras: - self.assertEqual(flatten_moras[mora_index], mora) - mora_index += 1 - if mora.consonant is not None: - self.assertTrue( - is_same_phoneme( - phoneme_data_list[phoneme_index], Phoneme(mora.consonant) - ) - ) - phoneme_index += 1 - self.assertTrue( - is_same_phoneme( - phoneme_data_list[phoneme_index], Phoneme(mora.vowel) - ) - ) - phoneme_index += 1 - if accent_phrase.pause_mora: - self.assertEqual(flatten_moras[mora_index], accent_phrase.pause_mora) - mora_index += 1 - self.assertTrue( - is_same_phoneme(phoneme_data_list[phoneme_index], Phoneme("pau")) - ) - phoneme_index += 1 - self.assertTrue( - is_same_phoneme(phoneme_data_list[phoneme_index], Phoneme("pau")) - ) - def test_update_length(self): # Inputs hello_hiho = _gen_hello_hiho_accent_phrases() diff --git a/voicevox_engine/tts_pipeline/tts_engine.py b/voicevox_engine/tts_pipeline/tts_engine.py index 69692ec40..03589fcc4 100644 --- a/voicevox_engine/tts_pipeline/tts_engine.py +++ b/voicevox_engine/tts_pipeline/tts_engine.py @@ -69,19 +69,6 @@ def split_mora(phonemes: list[Phoneme]) -> tuple[list[Phoneme | None], list[Phon return consonants, vowels -def pre_process( - accent_phrases: list[AccentPhrase], -) -> tuple[list[Mora], list[Phoneme]]: - """アクセント句系列から(前後の無音含まない)モーラ系列と(前後の無音含む)音素系列を抽出する""" - flatten_moras = to_flatten_moras(accent_phrases) - phonemes = to_flatten_phonemes(flatten_moras) - - # 前後無音の追加 - phonemes = [Phoneme("pau")] + phonemes + [Phoneme("pau")] - - return flatten_moras, phonemes - - def generate_silence_mora(length: float) -> Mora: """無音モーラの生成""" return Mora(text=" ", vowel="sil", vowel_length=length, pitch=0.0) @@ -360,7 +347,9 @@ def _create_one_hot( end_accent_phrase_list = np.array(end_accent_phrase_list, dtype=np.int64) # アクセント句系列から(前後の無音含まない)モーラ系列と(前後の無音含む)音素系列を抽出する - moras, phonemes = pre_process(accent_phrases) + moras = to_flatten_moras(accent_phrases) + phonemes = to_flatten_phonemes(moras) + phonemes = [Phoneme("pau")] + phonemes + [Phoneme("pau")] # 前後無音付加済みの音素系列から子音ID系列・母音ID系列を抽出する consonants, vowels = split_mora(phonemes)