Skip to content

Commit

Permalink
remove: pre_process()
Browse files Browse the repository at this point in the history
  • Loading branch information
tarepan committed Jan 8, 2024
1 parent 4513a79 commit dc237e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
37 changes: 0 additions & 37 deletions test/tts_pipeline/test_tts_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 3 additions & 14 deletions voicevox_engine/tts_pipeline/tts_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dc237e0

Please sign in to comment.