From 9c84ecb4fb211f9b6c4ad4087a19e3ac532ab57c Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Tue, 11 Mar 2014 17:34:14 +0100 Subject: [PATCH] Yaafe analyzer: simplify adaptation of process frames from TimeSide to Yaafe --- timeside/analyzer/yaafe.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/timeside/analyzer/yaafe.py b/timeside/analyzer/yaafe.py index 54b5088..ab069bb 100644 --- a/timeside/analyzer/yaafe.py +++ b/timeside/analyzer/yaafe.py @@ -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 -- 2.39.5