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

Fix formant without f0 #134

Merged
merged 1 commit into from
Jul 15, 2024
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
9 changes: 3 additions & 6 deletions server/voice_changer/RVC/pipeline/Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def exec(
with Timer2("Pipeline-Exec", False) as t: # NOQA
# 16000のサンプリングレートで入ってきている。以降この世界は16000で処理。
assert audio.dim() == 1, audio.dim()

formant_factor = 2 ** (formant_shift / 12)
formant_length = int(np.ceil(return_length * formant_factor))
t.record("pre-process")

# ピッチ検出
Expand Down Expand Up @@ -223,9 +226,6 @@ def exec(

feats = self._upscale(feats)[:, :audio_feats_len, :]
if self.use_f0:
formant_factor = 2 ** (formant_shift / 12)
formant_length = int(np.ceil(return_length * formant_factor))

pitch = pitch[:, -audio_feats_len:]
pitchf = pitchf[:, -audio_feats_len:] * (formant_length / return_length)
# pitchの推定が上手くいかない(pitchf=0)場合、検索前の特徴を混ぜる
Expand All @@ -239,9 +239,6 @@ def exec(
pitchff[pitchf < 1] = protect
pitchff = pitchff.unsqueeze(-1)
feats = feats * pitchff + feats_orig * (1 - pitchff)
else:
formant_factor = 0
formant_length = return_length

p_len = torch.tensor([audio_feats_len], device=self.device, dtype=torch.int64)

Expand Down
Loading