-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hi, I'm using the model to extract f0 features in real time for an audio recorded by the microphone.
The process to obtain f0 looks as follows for every 40ms of audio:
def get_praat_f0(audio, rate=16000):
frame_length = 16.0 # in ms
to_pad = int(frame_length / 1000 * rate) // 2
f0s = []
for y in audio.cpu().numpy().astype(np.float64):
y_pad = np.pad(y.squeeze(), (to_pad, to_pad), "constant", constant_values=0)
signal = basic.SignalObj(y_pad, rate)
pitch = pYAAPT.yaapt(signal, **{'frame_length': frame_length, 'frame_space': 4.0, 'nccf_thresh1': 0.25,
'tda_frame_length': 25.0})
f0s += [pitch.samp_values[None, None, :]]
f0 = np.vstack(f0s)
f0 = torch.from_numpy(f0).float()
return f0
The model tends to throw warnings and eventually crash after some time. When debugging it, it seems related to feeding it with silent parts of the audio. If I amplify the almost silent audio and send it again to the model, it doesn't crash.
Did this behavior happen to anyone else? I'd be grateful for suggestions on how to overcome this :)
Here is the error:
File "/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py", line 411, in yaapt
pitch.set_values(final_pitch, signal.size)
File "/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py", line 103, in set_values
self.values = self.upsample(self.samp_values, file_size, 0, 0,
File "/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py", line 228, in upsample
tot_interval = np.arange(int(up_interval[0]-(self.frame_jump/2)),
IndexError: index 0 is out of bounds for axis 0 with size 0
And here are the warnings that comes before it:
phi[lag_min:lag_max] = formula_nume/np.sqrt(formula_denom)
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py:1001: RuntimeWarning: invalid value encountered in greater
vec_back = (phi[lag_min+center:lag_max-center+1] >
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py:1003: RuntimeWarning: invalid value encountered in greater
vec_forw = (phi[lag_min+center:lag_max-center+1] >
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py:1005: RuntimeWarning: invalid value encountered in greater
above_thresh = phi[lag_min+center:lag_max-center+1] > merit_thresh1
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/numpy/core/fromnumeric.py:3334: RuntimeWarning: Mean of empty slice.
return _methods._mean(a, axis=axis, dtype=dtype,
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/numpy/core/_methods.py:161: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/numpy/core/_methods.py:216: RuntimeWarning: Degrees of freedom <= 0 for slice
ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/numpy/core/_methods.py:185: RuntimeWarning: invalid value encountered in true_divide
arrmean = um.true_divide(
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/numpy/core/_methods.py:209: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/scipy/signal/signaltools.py:1396: UserWarning: kernel_size exceeds volume extent: the volume will be zero-padded.
warnings.warn('kernel_size exceeds volume extent: the volume will be '
/private/home/orik/.conda/envs/speech_enhancement_fromscratch3_py38_pt16/lib/python3.8/site-packages/amfm_decompy/pYAAPT.py:627: RuntimeWarning: invalid value encountered in multiply