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

整理: フレーム計算の _to_frame による共通化 #844

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
22 changes: 6 additions & 16 deletions voicevox_engine/synthesis_engine/synthesis_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,12 @@ def calc_frame_per_phoneme(query: AudioQuery, moras: List[Mora]):
# Apply: グローバル特徴量による補正(話速)
moras = apply_speed_scale(moras, query)

# 音素あたりの継続長
sec_per_phoneme = numpy.array(
[
length
for mora in moras
for length in (
[mora.consonant_length] if mora.consonant is not None else []
)
+ [mora.vowel_length]
],
dtype=numpy.float32,
)
# 音素あたりのフレーム長。端数丸め。
framerate = 24000 / 256 # framerate 93.75 [frame/sec]
frame_per_phoneme = numpy.round(sec_per_phoneme * framerate).astype(numpy.int32)

frame_per_phoneme: list[ndarray] = []
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
for mora in moras:
if mora.consonant:
frame_per_phoneme.append(_to_frame(mora.consonant_length))
frame_per_phoneme.append(_to_frame(mora.vowel_length))
frame_per_phoneme = numpy.array(frame_per_phoneme)
return frame_per_phoneme


Expand Down