]> git.parisson.com Git - timeside.git/commitdiff
Enable TimeSide to work without external libraries such as Yafe, Aubio, Vamp
authorThomas Fillon <thomas@parisson.com>
Mon, 14 Apr 2014 21:02:41 +0000 (23:02 +0200)
committerThomas Fillon <thomas@parisson.com>
Mon, 14 Apr 2014 21:02:41 +0000 (23:02 +0200)
Add automatic detection of Yaafe, Aubio and Vamp and add a conditional import of related analyzers in timeside/anaylers/__init__.py

tests/test_aubio_melenergy.py
tests/test_aubio_mfcc.py
tests/test_aubio_pitch.py
tests/test_aubio_specdesc.py
tests/test_aubio_temporal.py
tests/test_yaafe.py
timeside/analyzer/__init__.py
timeside/analyzer/limsi_sad.py
timeside/analyzer/yaafe.py

index 274e032e238d7a191b25802b86007ce3e0a3aa8c..16506ac893094927a28be9c898c57b8c8de8b1d3 100755 (executable)
@@ -2,8 +2,12 @@
 
 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):
index 8bcffef92207ea18513c81d380a518c31271c572..e774acae8c72364a5d2ed17ff449b78ddd83c469 100755 (executable)
@@ -2,8 +2,12 @@
 
 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):
index 557e7978c10241d25aa49806909abefd5ece298c..9de6b81d4a2cfab6c744de673d10e867d0f62e36 100755 (executable)
@@ -2,8 +2,12 @@
 
 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):
index f4341ec6bc393f51b620cec92e351af4538407e6..51dfaff5d4423cbc75f46858f279c4fb0a4f1050 100755 (executable)
@@ -2,8 +2,12 @@
 
 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):
index 9ffba1bc844cbf2b38be6eaf2adce350eee8dbc5..9f6d5acf302f2c6a16e0fa0a4e94922fcc6be9b6 100755 (executable)
@@ -2,8 +2,12 @@
 
 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):
index d0c7142810f62f64fbcf69712691cc9cc5d41df5..714893fb996bffdf7a3e64fdd75fe31938ee8ba9 100755 (executable)
@@ -2,9 +2,13 @@
 
 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):
index 27aa32d344913f70c19ae31541a92b4ff2b89b6b..3f5eb52b9eabeb5b38d3ecd46e5a5015d2699519 100644 (file)
@@ -1,17 +1,41 @@
 # -*- 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
index 5586aad607089889c2c4425b95b763b5ce96771a..5a5afa03a12c11f54a33ab06a658496c83795375 100644 (file)
@@ -23,8 +23,10 @@ from timeside.core import implements, interfacedoc
 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
index ab069bb55b5b39f17e2a811df776487b023f1441..1a3fa2c71b8ff5d14cb5af18419da9ed33ffd56f 100644 (file)
@@ -27,7 +27,9 @@ Created on Thu Jun 13 16:05:02 2013
 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