Skip to content

Commit afb42b0

Browse files
authored
fix: fix compute_f0_crepe returning wrong length (#42)
1 parent 695c773 commit afb42b0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/so_vits_svc_fork/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import torchcrepe
1414
from numpy import dtype, float32, ndarray
1515
from scipy.io.wavfile import read
16-
from torch import FloatTensor
16+
from torch import FloatTensor, Tensor
1717
from tqdm import tqdm
1818

1919
LOG = getLogger(__name__)
@@ -219,7 +219,7 @@ def compute_f0_crepe(
219219
# (T) -> (1, T)
220220
audio = audio.detach()
221221

222-
pitch = torchcrepe.predict(
222+
pitch: Tensor = torchcrepe.predict(
223223
audio,
224224
sampling_rate,
225225
hop_length,
@@ -231,7 +231,10 @@ def compute_f0_crepe(
231231
pad=True,
232232
)
233233

234-
return pitch.detach().cpu().numpy()[0]
234+
f0 = pitch.squeeze(0).cpu().numpy()
235+
p_len = p_len or wav_numpy.shape[0] // hop_length
236+
f0 = _resize_f0(f0, p_len)
237+
return f0
235238

236239

237240
def compute_f0(

0 commit comments

Comments
 (0)