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

整理: tts_engine モジュール内のプライベートな関数をリネーム、テストを整理 #1435

Merged
merged 22 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
17bc276
refactor: `to_flatten_moras()` の docstring を簡略化
tarepan Jun 25, 2024
cfcd4fc
refactor: `to_flatten_phonemes()` をプライベートへリネーム、テストを明確化
tarepan Jun 25, 2024
0a67dfd
refactor: `generate_silence_mora()` をプライベート化
tarepan Jun 25, 2024
f4e2b85
refactor: `_apply_interrogative_upspeak()` をプライベート化
tarepan Jun 25, 2024
5fdb400
refactor: `apply_prepost_silence()` をプライベート化、テストを簡略化
tarepan Jun 25, 2024
eac831e
refactor: `apply_speed_scale()` をプライベート化、テストを簡略化
tarepan Jun 25, 2024
f83b773
refactor: `apply_pitch_scale()` をプライベート化、テストを整理
tarepan Jun 25, 2024
7410df7
refactor: `apply_intonation_scale()` をプライベート化、テストをフォーマット
tarepan Jun 25, 2024
9162a6d
refactor: `apply_pause_length()` と `apply_pause_length_scale()` をプライベート化
tarepan Jun 25, 2024
ebb7f0a
refactor: `apply_volume_scale()` をプライベート化、テストをフォーマット
tarepan Jun 25, 2024
e464808
refactor: `apply_output_sampling_rate()` をプライベート化、テストをフォーマット
tarepan Jun 25, 2024
155d214
refactor: `apply_output_stereo()` をプライベート化、テストをフォーマット
tarepan Jun 25, 2024
757ec7b
refactor: `query_to_decoder_feature()` をプライベート化、テストを簡略化
tarepan Jun 25, 2024
d88c632
refactor: `count_frame_per_unit()` をプライベート化、テストを簡略化
tarepan Jun 25, 2024
67afb82
refactor: `calc_phoneme_lengths()` をプライベート化
tarepan Jun 25, 2024
5046777
refactor: `notes_to_keys_and_phonemes()` をプライベート化
tarepan Jun 25, 2024
17fbf0c
refactor: `frame_query_to_sf_decoder_feature()` をプライベート化
tarepan Jun 25, 2024
a65e211
Merge branch 'master' into refactor/tts_engine_format
tarepan Jun 25, 2024
1f29fc6
Merge branch 'master' into refactor/tts_engine_format
tarepan Jun 26, 2024
660674a
refactor: 定数 `T` を関数化
tarepan Jun 26, 2024
cdebbf7
fix: type
tarepan Jun 26, 2024
9ddc6d2
fix: lint
tarepan Jun 26, 2024
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
40 changes: 20 additions & 20 deletions test/unit/tts_pipeline/test_tts_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from voicevox_engine.tts_pipeline.text_analyzer import text_to_accent_phrases
from voicevox_engine.tts_pipeline.tts_engine import (
TTSEngine,
apply_interrogative_upspeak,
_apply_interrogative_upspeak,
_to_flatten_phonemes,
to_flatten_moras,
to_flatten_phonemes,
)

from .test_text_analyzer import stub_unknown_features_koxx
Expand Down Expand Up @@ -105,21 +105,21 @@ def is_model_loaded(self, style_id: str) -> bool:


def test_to_flatten_phonemes() -> None:
"""Test `to_flatten_phonemes`."""
"""Test `_to_flatten_phonemes()`."""
# Inputs
moras = [
gen_mora(" ", None, None, "sil", 2 * 0.01067, 0.0),
gen_mora("ヒ", "h", 2 * 0.01067, "i", 4 * 0.01067, 5.0),
gen_mora(" ", None, None, "sil", 6 * 0.01067, 0.0),
]

# Expects
true_phonemes = ["pau", "h", "i", "pau"]

true_phoneme_strs = ["pau", "h", "i", "pau"]
# Outputs
phonemes = list(map(lambda p: p._phoneme, to_flatten_phonemes(moras)))
phonemes = _to_flatten_phonemes(moras)
phoneme_strs = list(map(lambda p: p._phoneme, phonemes))

assert true_phonemes == phonemes
# Test
assert true_phoneme_strs == phoneme_strs


def _gen_hello_hiho_accent_phrases() -> list[AccentPhrase]:
Expand Down Expand Up @@ -531,7 +531,7 @@ def test_upspeak_voiced_last_mora() -> None:
)
]
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -542,7 +542,7 @@ def test_upspeak_voiced_last_mora() -> None:
expected = koreha_arimasuka_base_expected()
expected[-1].is_interrogative = True
# Outputs
outputs = apply_interrogative_upspeak(inputs, False)
outputs = _apply_interrogative_upspeak(inputs, False)
# Test
assert expected == outputs

Expand All @@ -552,7 +552,7 @@ def test_upspeak_voiced_last_mora() -> None:
# Expects
expected = koreha_arimasuka_base_expected()
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand Down Expand Up @@ -583,7 +583,7 @@ def nn_base_expected() -> list[AccentPhrase]:
# Expects
expected = nn_base_expected()
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -604,7 +604,7 @@ def nn_base_expected() -> list[AccentPhrase]:
)
]
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -615,7 +615,7 @@ def nn_base_expected() -> list[AccentPhrase]:
expected = nn_base_expected()
expected[-1].is_interrogative = True
# Outputs
outputs = apply_interrogative_upspeak(inputs, False)
outputs = _apply_interrogative_upspeak(inputs, False)
# Test
assert expected == outputs

Expand Down Expand Up @@ -646,7 +646,7 @@ def ltu_base_expected() -> list[AccentPhrase]:
# Expects
expected = ltu_base_expected()
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -657,7 +657,7 @@ def ltu_base_expected() -> list[AccentPhrase]:
expected = ltu_base_expected()
expected[-1].is_interrogative = True
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -668,7 +668,7 @@ def ltu_base_expected() -> list[AccentPhrase]:
expected = ltu_base_expected()
expected[-1].is_interrogative = True
# Outputs
outputs = apply_interrogative_upspeak(inputs, False)
outputs = _apply_interrogative_upspeak(inputs, False)
# Test
assert expected == outputs

Expand Down Expand Up @@ -699,7 +699,7 @@ def su_base_expected() -> list[AccentPhrase]:
# Expects
expected = su_base_expected()
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -720,7 +720,7 @@ def su_base_expected() -> list[AccentPhrase]:
)
]
# Outputs
outputs = apply_interrogative_upspeak(inputs, True)
outputs = _apply_interrogative_upspeak(inputs, True)
# Test
assert expected == outputs

Expand All @@ -731,6 +731,6 @@ def su_base_expected() -> list[AccentPhrase]:
expected = su_base_expected()
expected[-1].is_interrogative = True
# Outputs
outputs = apply_interrogative_upspeak(inputs, False)
outputs = _apply_interrogative_upspeak(inputs, False)
# Test
assert expected == outputs
Loading
Loading