]> git.parisson.com Git - timeside.git/commitdiff
Yaafe analyzer: simplify adaptation of process frames from TimeSide to Yaafe
authorThomas Fillon <thomas@parisson.com>
Tue, 11 Mar 2014 16:34:14 +0000 (17:34 +0100)
committerThomas Fillon <thomas@parisson.com>
Tue, 11 Mar 2014 16:34:14 +0000 (17:34 +0100)
timeside/analyzer/yaafe.py

index 54b50887a93136e843aeff824904086be61a1039..ab069bb55b5b39f17e2a811df776487b023f1441 100644 (file)
@@ -29,6 +29,7 @@ from timeside.analyzer.core import Analyzer
 from timeside.api import IAnalyzer
 from yaafelib import *
 import numpy
+from timeside.analyzer.preprocessors import downmix_to_mono
 
 
 class Yaafe(Analyzer):
@@ -83,14 +84,13 @@ class Yaafe(Analyzer):
     def unit():
         return ''
 
+    @downmix_to_mono
     def process(self, frames, eod=False):
         # do process things...
-        # Downmixing to mono and convert to float64 for compatibility with
-        # Yaafe
-        yaafe_frames = frames.sum(
-            axis=-1, dtype=numpy.float64) / frames.shape[-1]
-        # Reshape for compatibility with Yaafe input format
-        yaafe_frames.shape = (1, yaafe_frames.shape[0])
+        # Convert to float64and reshape
+        # for compatibility with Yaafe engine
+        yaafe_frames = frames.astype(numpy.float64).reshape(1,-1)
+
         # write audio array on 'audio' input
         self.yaafe_engine.writeInput('audio', yaafe_frames)
         # process available data