Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

廃止: pre_process() #976

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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