def _estimate_f0(ex):
    'Estimate the fundamental frequency using CREPE and add to example.'
    ex = ex.copy()
    beam.metrics.Metrics.counter(split, 'estimate-f0').inc()
    (_, f0_hz, f0_confidence, _) = tfds.core.lazy_imports.crepe.predict(ex['audio'], sr=_AUDIO_RATE, viterbi=True, step_size=(1000 / _F0_AND_LOUDNESS_RATE), verbose=0)
    f0_midi = tfds.core.lazy_imports.librosa.core.hz_to_midi(f0_hz)
    f0_midi[(f0_midi == (- np.inf))] = 0
    f0_confidence = np.nan_to_num(f0_confidence)
    ex['f0'] = {'hz': f0_hz.astype(np.float32), 'midi': f0_midi.astype(np.float32), 'confidence': f0_confidence.astype(np.float32)}
    return ex
Estimate the fundamental frequency using CREPE and add to example.
def _estimate_f0(ex):
    
    ex = ex.copy()
    beam.metrics.Metrics.counter(split, 'estimate-f0').inc()
    (_, f0_hz, f0_confidence, _) = tfds.core.lazy_imports.crepe.predict(ex['audio'], sr=_AUDIO_RATE, viterbi=True, step_size=(1000 / _F0_AND_LOUDNESS_RATE), verbose=0)
    f0_midi = tfds.core.lazy_imports.librosa.core.hz_to_midi(f0_hz)
    f0_midi[(f0_midi == (- np.inf))] = 0
    f0_confidence = np.nan_to_num(f0_confidence)
    ex['f0'] = {'hz': f0_hz.astype(np.float32), 'midi': f0_midi.astype(np.float32), 'confidence': f0_confidence.astype(np.float32)}
    return ex