Skip to content

Commit

Permalink
Merge pull request #134 from deiteris/formant-shift
Browse files Browse the repository at this point in the history
Fix formant without f0
  • Loading branch information
deiteris authored Jul 15, 2024
2 parents 5cad5cc + 8132934 commit fe9d2e5
Showing 1 changed file with 3 additions and 6 deletions.
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

0 comments on commit fe9d2e5

Please sign in to comment.