From: Guillaume Pellerin Date: Tue, 21 Jan 2014 16:53:29 +0000 (+0100) Subject: various minor syntax fixes on IRIT analyzers X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=7eea13003a89eb8db704dc3fd7ffa393dcba5264;p=timeside.git various minor syntax fixes on IRIT analyzers --- diff --git a/timeside/analyzer/irit_diverg.py b/timeside/analyzer/irit_diverg.py index e15d2fe..c26eb03 100644 --- a/timeside/analyzer/irit_diverg.py +++ b/timeside/analyzer/irit_diverg.py @@ -26,17 +26,12 @@ from timeside.api import IAnalyzer from numpy import spacing from collections import deque + class ModelLongTerm(object): ''' ''' def __init__(self,ordre,echantillon): - ''' - - Constructor - - ''' - self.ordre = ordre self.ft = [0]*(ordre+2) self.ftm1 = [0]*(ordre+2) @@ -59,7 +54,7 @@ class ModelLongTerm(object): self.erreur_residuelle = self.et[ik] self.variance_erreur_residuelle =self.variance_f[ik] - def miseAJour(self,echantillon): + def update(self,echantillon): ''' ''' @@ -74,7 +69,6 @@ class ModelLongTerm(object): self.variance_b[0] = self.variance_f[0] ik = min([self.ordre,self.length-1]) - for n in xrange(ik+1) : oubli =1.0/float(self.length-n) @@ -93,10 +87,6 @@ class ModelLongTerm(object): self.variance_erreur_residuelle =self.variance_f[ik+1] def __str__(self): - ''' - - ''' - s = 'Model Long Terme\n' s += '\tOrdre\t\t%d\n'%self.ordre s += '\tLongueur\t%d\n'%self.length @@ -125,18 +115,11 @@ class ModelLongTerm(object): return s - class ModelCourtTrerm(object): ''' ''' def __init__(self,ordre,buff): - ''' - - Constructor - - ''' - self.N = len(buff) self.ordre = ordre self.erreur_residuelle = 0 @@ -192,7 +175,7 @@ class ModelCourtTrerm(object): for i in range(self.ordre+1) : self.erreur_residuelle = self.erreur_residuelle +self.AI[i]*self.buff[self.N-i-1] - def miseAJour(self,echantillon): + def update(self,echantillon): self.dernier_echantillon = self.buff.popleft() self.buff.append(echantillon) for tau in xrange(1,self.ordre+1): @@ -277,13 +260,12 @@ def segment(data,fe,ordre=2,Lmin=0.02,lamb=40.0,biais=-0.2,with_backward=True): echantillon= data[t] longTerme = ModelLongTerm(ordre,echantillon) - while (not rupture) and t < long_signal-1 : - + while (not rupture) and t < long_signal-1 : t+=1 # Mise à jour du long terme echantillon = data[t] - longTerme.miseAJour(echantillon) + longTerme.update(echantillon) # Si l'ecart avec la dernière rupture est suffisant # pour utiliser le modèle court terme @@ -295,7 +277,7 @@ def segment(data,fe,ordre=2,Lmin=0.02,lamb=40.0,biais=-0.2,with_backward=True): # Mise à jour du modèle court terme if t-rupt_last > Lmin : - courtTerme.miseAJour(echantillon) + courtTerme.update(echantillon) # mise à jour du critère Wn = Wn+calculDistance(longTerme,courtTerme)-biais @@ -314,7 +296,6 @@ def segment(data,fe,ordre=2,Lmin=0.02,lamb=40.0,biais=-0.2,with_backward=True): # Positionnement de la rupture au dernier point maximum t_rupt = maxi[1] - # Si une rupture à été detecté avec un modèle stable (Wn à croit) if t_rupt > -1 : @@ -351,8 +332,6 @@ def segment(data,fe,ordre=2,Lmin=0.02,lamb=40.0,biais=-0.2,with_backward=True): class IRITDiverg(Analyzer): implements(IAnalyzer) ''' - - ''' def __init__(self, blocksize=1024, stepsize=None) : @@ -360,7 +339,6 @@ class IRITDiverg(Analyzer): self.parents.append(Waveform()) self.ordre = 2 - @interfacedoc def setup(self, channels=None, samplerate=None,blocksize=None, totalframes=None): super(IRITDiverg, self).setup(channels,samplerate,blocksize,totalframes) @@ -384,16 +362,12 @@ class IRITDiverg(Analyzer): return "Stationnary Segments" def process(self, frames, eod=False): - ''' - - ''' return frames, eod def post_process(self): data = list(self.process_pipe.results['waveform_analyzer'].data) frontieres = segment(data,self.samplerate(),self.ordre) - segs = self.new_result(data_mode='label', time_mode='event') segs.id_metadata.id += '.' + 'segments' segs.id_metadata.name += ' ' + 'Segments' diff --git a/timeside/analyzer/irit_monopoly.py b/timeside/analyzer/irit_monopoly.py index 6ad8dce..e45ac3f 100644 --- a/timeside/analyzer/irit_monopoly.py +++ b/timeside/analyzer/irit_monopoly.py @@ -25,6 +25,8 @@ from timeside.analyzer.core import Analyzer from timeside.api import IAnalyzer from aubio import pitch import numpy + + class IRITMonopoly(Analyzer): implements(IAnalyzer) ''' @@ -66,10 +68,6 @@ class IRITMonopoly(Analyzer): return "Labeled Monophonic/Polyphonic segments" def process(self, frames, eod=False): - ''' - - ''' - self.decisionLen = 1.0;# in seconds pf = self.aubio_pitch(frames.T[0]) self.pitches += [pf[0]] diff --git a/timeside/analyzer/irit_music_.py b/timeside/analyzer/irit_music_.py index a05c26c..783bb52 100644 --- a/timeside/analyzer/irit_music_.py +++ b/timeside/analyzer/irit_music_.py @@ -29,6 +29,8 @@ from numpy import logical_and,array, hamming, dot, mean, float, arange, nonzero from numpy.fft import rfft from scipy.signal import firwin, lfilter from pylab import plot,show + + class IRITMusicLDN(Analyzer): implements(IAnalyzer) @@ -58,13 +60,10 @@ class IRITMusicLDN(Analyzer): return "Music confidence indexes" def process(self, frames, eod=False): - return frames,eod - def post_process(self): ''' - ''' segList = self.process_pipe.results['irit_diverg.segments'].time diff --git a/timeside/analyzer/irit_music_SLN.py b/timeside/analyzer/irit_music_SLN.py index 3a7a638..df2c885 100644 --- a/timeside/analyzer/irit_music_SLN.py +++ b/timeside/analyzer/irit_music_SLN.py @@ -30,6 +30,7 @@ from numpy.fft import rfft from scipy.signal import firwin, lfilter from pylab import plot,show + class IRITMusicSLN(Analyzer): implements(IAnalyzer) @@ -59,10 +60,8 @@ class IRITMusicSLN(Analyzer): return "Music confidence indexes" def process(self, frames, eod=False): - return frames,eod - def post_process(self): ''' diff --git a/timeside/analyzer/irit_music_SNB.py b/timeside/analyzer/irit_music_SNB.py index 15dce01..a18291e 100644 --- a/timeside/analyzer/irit_music_SNB.py +++ b/timeside/analyzer/irit_music_SNB.py @@ -30,7 +30,9 @@ from numpy.fft import rfft from scipy.signal import firwin, lfilter from pylab import plot,show + class IRITMusicSNB(Analyzer): + implements(IAnalyzer) def __init__(self, blocksize=1024, stepsize=None) : @@ -59,10 +61,8 @@ class IRITMusicSNB(Analyzer): return "Music confidence indexes" def process(self, frames, eod=False): - return frames,eod - def post_process(self): ''' diff --git a/timeside/analyzer/irit_speech_4hz.py b/timeside/analyzer/irit_speech_4hz.py index ea86677..32789d0 100644 --- a/timeside/analyzer/irit_speech_4hz.py +++ b/timeside/analyzer/irit_speech_4hz.py @@ -86,10 +86,6 @@ class IRITSpeech4Hz(Analyzer): return "Speech confidences indexes" def process(self, frames, eod=False): - ''' - - ''' - frames = frames.T[0] # windowing of the frame (could be a changeable property) w = frames * hamming(len(frames)) @@ -99,7 +95,7 @@ class IRITSpeech4Hz(Analyzer): e = dot(f ** 2, self.melFilter) self.energy4hz.append(e) - + return frames, eod def post_process(self): diff --git a/timeside/analyzer/irit_speech_entropy.py b/timeside/analyzer/irit_speech_entropy.py index 8d13ab4..bb09b89 100644 --- a/timeside/analyzer/irit_speech_entropy.py +++ b/timeside/analyzer/irit_speech_entropy.py @@ -64,7 +64,6 @@ class IRITSpeechEntropy(Analyzer): return frames, eod def post_process(self): - entropyValue = array(self.entropyValue) w = self.modulLen * self.samplerate() / self.blocksize() modulentropy = computeModulation(entropyValue, w, False)