Add automatic detection of Yaafe, Aubio and Vamp and add a conditional import of related analyzers in timeside/anaylers/__init__.py
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer.aubio_melenergy import AubioMelEnergy
+from timeside.analyzer import WITH_AUBIO
+if WITH_AUBIO:
+ from timeside.analyzer.aubio_melenergy import AubioMelEnergy
+
+@unittest.skipIf(not WITH_AUBIO, 'Aubio library is not available')
class TestAubioMelEnergy(unittest.TestCase):
def setUp(self):
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer.aubio_mfcc import AubioMfcc
+from timeside.analyzer import WITH_AUBIO
+if WITH_AUBIO:
+ from timeside.analyzer.aubio_mfcc import AubioMfcc
+
+@unittest.skipIf(not WITH_AUBIO, 'Aubio library is not available')
class TestAubioMfcc(unittest.TestCase):
def setUp(self):
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer.aubio_pitch import AubioPitch
+from timeside.analyzer import WITH_AUBIO
+if WITH_AUBIO:
+ from timeside.analyzer.aubio_pitch import AubioPitch
+
+@unittest.skipIf(not WITH_AUBIO, 'Aubio library is not available')
class TestAubioPitch(unittest.TestCase):
def setUp(self):
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer.aubio_specdesc import AubioSpecdesc
+from timeside.analyzer import WITH_AUBIO
+if WITH_AUBIO:
+ from timeside.analyzer.aubio_specdesc import AubioSpecdesc
+
+@unittest.skipIf(not WITH_AUBIO, 'Aubio library is not available')
class TestAubioSpecdesc(unittest.TestCase):
def setUp(self):
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer.aubio_temporal import AubioTemporal
+from timeside.analyzer import WITH_AUBIO
+if WITH_AUBIO:
+ from timeside.analyzer.aubio_temporal import AubioTemporal
+
+@unittest.skipIf(not WITH_AUBIO, 'Aubio library is not available')
class TestAubioTemporal(unittest.TestCase):
def setUp(self):
from unit_timeside import *
from timeside.decoder import *
-from timeside.analyzer import Yaafe
-from yaafelib import DataFlow,FeaturePlan
+from timeside.analyzer import WITH_YAAFE
+if WITH_YAAFE:
+ from timeside.analyzer import Yaafe
+ from yaafelib import DataFlow, FeaturePlan
+
+@unittest.skipIf(not WITH_YAAFE, 'Yaafe library is not available')
class TestYaafe(unittest.TestCase):
def setUp(self):
# -*- coding: utf-8 -*-
+# ----- Load external libraries ------
+# Aubio
+try:
+ WITH_AUBIO = True
+ from aubio_temporal import AubioTemporal
+ from aubio_pitch import AubioPitch
+ from aubio_mfcc import *
+ from aubio_melenergy import *
+ from aubio_specdesc import *
+except ImportError:
+ WITH_AUBIO = False
+
+# Yaafe
+try:
+ WITH_YAAFE = True
+ from yaafe import *
+
+except ImportError:
+ WITH_YAAFE = False
+
+# Vamp Plugins
+try:
+ from vamp_plugin import VampSimpleHost
+ VampSimpleHost.SimpleHostProcess(['-v'])
+ WITH_VAMP = True
+except OSError:
+ WITH_VAMP = False
+
+
+# ----- Load timeside analyzers ------
from level import Level
from dc import MeanDCShift
-from aubio_temporal import AubioTemporal
-from aubio_pitch import AubioPitch
-from aubio_mfcc import *
-from aubio_melenergy import *
-from aubio_specdesc import *
-from yaafe import *
from spectrogram import Spectrogram
from waveform import Waveform
-from vamp_plugin import VampSimpleHost
from irit_speech_entropy import IRITSpeechEntropy
from irit_speech_4hz import IRITSpeech4Hz
from odf import OnsetDetectionFunction
-from limsi_sad import LimsiSad
+if WITH_YAAFE:
+ from limsi_sad import LimsiSad
from timeside.analyzer.core import Analyzer
from timeside.api import IAnalyzer
import timeside
-from yaafe import Yaafe
-import yaafelib
+from timeside.analyzer import WITH_YAAFE
+if WITH_YAAFE:
+ from yaafe import Yaafe
+ import yaafelib
import numpy as N
import pickle
import os.path
from timeside.core import implements, interfacedoc
from timeside.analyzer.core import Analyzer
from timeside.api import IAnalyzer
-from yaafelib import *
+from timeside.analyzer import WITH_YAAFE
+if WITH_YAAFE:
+ from yaafelib import *
import numpy
from timeside.analyzer.preprocessors import downmix_to_mono