]> git.parisson.com Git - timeside.git/commitdiff
various minor syntax fixes on IRIT analyzers
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 21 Jan 2014 16:53:29 +0000 (17:53 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 21 Jan 2014 16:53:29 +0000 (17:53 +0100)
timeside/analyzer/irit_diverg.py
timeside/analyzer/irit_monopoly.py
timeside/analyzer/irit_music_.py
timeside/analyzer/irit_music_SLN.py
timeside/analyzer/irit_music_SNB.py
timeside/analyzer/irit_speech_4hz.py
timeside/analyzer/irit_speech_entropy.py

index e15d2fe42869b67dcc387d6158a95adbe71f7d75..c26eb03248ce0d0c95aeff4f3841e555879e43e1 100644 (file)
@@ -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'
index 6ad8dce22716f56c00ba530259575bc41d99b25f..e45ac3f1522e69cb3d81f7699ba1e45304effccc 100644 (file)
@@ -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]]
index a05c26c47a3cd2aeb529e88fdc73e33d96b81919..783bb52104c8d629dea46cf96f8da92b248e3915 100644 (file)
@@ -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
index 3a7a63824b4d8f94fbc763f8619c67e932f5ecce..df2c8850e009605205cfa2a6bcb9c23d51b3215b 100644 (file)
@@ -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):
         '''
 
index 15dce01522d1fce9548f2f12b69277b3a57806ac..a18291ef32b4b26b65cd9a102168b96c44f47fa6 100644 (file)
@@ -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):
         '''
 
index ea8667796e33cbb7be7343f7ccb0b7464d14fe33..32789d0c966451a7f440b183a2251b13b870f1b3 100644 (file)
@@ -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):
index 8d13ab4bf0ddb271686b985ebf65549be9ce9a53..bb09b89e28969db643c8587d249cf919ef228c45 100644 (file)
@@ -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)