From e9d5467cf5279fa241204836c6a4682c50dc07cf Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Mon, 14 Apr 2014 23:02:41 +0200 Subject: [PATCH] Enable TimeSide to work without external libraries such as Yafe, Aubio, Vamp Add automatic detection of Yaafe, Aubio and Vamp and add a conditional import of related analyzers in timeside/anaylers/__init__.py --- timeside/analyzer/__init__.py | 40 +++++++++++++++++++++++++++------- timeside/analyzer/limsi_sad.py | 6 +++-- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/timeside/analyzer/__init__.py b/timeside/analyzer/__init__.py index 27aa32d..3f5eb52 100644 --- a/timeside/analyzer/__init__.py +++ b/timeside/analyzer/__init__.py @@ -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 diff --git a/timeside/analyzer/limsi_sad.py b/timeside/analyzer/limsi_sad.py index 5586aad..5a5afa0 100644 --- a/timeside/analyzer/limsi_sad.py +++ b/timeside/analyzer/limsi_sad.py @@ -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 -- 2.39.5