]> git.parisson.com Git - timeside.git/commitdiff
AubioPitch: prevent NaN in result by converting them to zero
authorThomas Fillon <thomas@parisson.com>
Tue, 11 Mar 2014 09:21:03 +0000 (10:21 +0100)
committerThomas Fillon <thomas@parisson.com>
Tue, 11 Mar 2014 09:21:03 +0000 (10:21 +0100)
timeside/analyzer/aubio_pitch.py

index cec72917cdee6ac4837f693d2e1b845ef574ae99..6769445a47bf534b28763c00b9896352708fcf0c 100644 (file)
@@ -24,7 +24,7 @@ from .core import Analyzer
 from ..api import IAnalyzer
 from preprocessors import downmix_to_mono, frames_adapter
 from aubio import pitch
-
+import numpy as np
 
 class AubioPitch(Analyzer):
     """Aubio Pitch estimation analyzer"""
@@ -72,7 +72,7 @@ class AubioPitch(Analyzer):
     def process(self, frames, eod=False):
         #time = self.block_read * self.input_stepsize * 1. / self.samplerate()
         self.pitches += [self.aubio_pitch(frames)[0]]
-        self.pitch_confidences += [self.aubio_pitch.get_confidence()]
+        self.pitch_confidences += [np.nan_to_num(self.aubio_pitch.get_confidence())]
         self.block_read += 1
         return frames, eod