Beispiel #1
0
 def parse_progress(self, line):
     if self.duration == None:
         match = self.re_duration.search(line)
         if match:
             self.duration = subutils.ts2ms(match.group(0)[10:21])
     else:
         match = self.re_position.search(line)
         if match:
             self.progress = subutils.ts2ms(match.group(0)[5:]) / float(self.duration)
             self.emit('progress', self.progress if self.progress <= 1 else 1)
Beispiel #2
0
 def parse_progress(self, line):
     if self.duration == None:
         match = self.re_duration.search(line)
         if match:
             self.duration = subutils.ts2ms(match.group(0)[10:21])
     else:
         match = self.re_position.search(line)
         if match:
             progress = subutils.ts2ms(match.group(0)[5:]) / self.duration
             GObject.idle_add(self.signal_progress,
                              float(progress if progress <= 1 else 1))
Beispiel #3
0
 def parse_progress(self, line):
     if self.duration == None:
         match = self.re_duration.search(line)
         if match:
             self.duration = subutils.ts2ms(match.group(0)[10:21])
     else:
         match = self.re_position.search(line)
         if match:
             self.progress = subutils.ts2ms(
                 match.group(0)[5:]) / self.duration
             self.emit('progress',
                       self.progress if self.progress <= 1 else 1)
Beispiel #4
0
 def msec(self, timeData):
     if type(timeData) == isinstance(timeData, timeStamp):
         if self.__msec != timeData.__msec:
             self.changed = True
         self.__msec = timeData.__msec
     if (type(timeData) == int) or (type(timeData) == float):
         if self.__msec != int(timeData):
             self.changed = True
         self.__msec = timeData
     if type(timeData) == str and subutils.is_timestamp(timeData):
         if self.__msec != subutils.ts2ms(timeData):
             self.changed = True
         self.__msec = subutils.ts2ms(timeData)
Beispiel #5
0
 def __add__(self, other):
     if type(other) == int or type(other) == float:
         return timeStamp(self.__msec + other)
     if isinstance(other, timeStamp):
         return timeStamp(self.__msec + other.__msec)
     if type(other) == str:
         if not subutils.is_timestamp(other):
             raise Exception(
                 "Expected Integer, Timestamp or Timestamp class object")
         return timeStamp(self.__msec + subutils.ts2ms(other))
Beispiel #6
0
def get_spect(data, audio_rate = 8000):
    return signal.spectrogram( data, audio_rate, scaling = 'spectrum' )

def get_spect_from_file(filename, audio_rate = 8000):
    return signal.spectrogram( open_data(filename), audio_rate, scaling = 'spectrum' )

def normalize_spec(spec):
    spec_data = spec[2] - spec[2].mean()
    spec_data //= spec_data.std()
    return (spec[0], spec[1], spec_data)

def t_slice(arr, startms, stopms):
    startidx = iround(startms / 8)
    stopidx = iround(stopms / 8)
    return arr[startidx:stopidx]

if __name__ == "__main__":
    from subutils import ts2ms

    src_data = open_data('/home/phantome/tmp2/src-xsubedit.raw')
    dst_data = open_data('/home/phantome/tmp2/dst-xsubedit.raw')
    #spec1 = normalize_spec(get_spect(src_data))
    #spec2 = normalize_spec(get_spect(dst_data))

    #print 'calc matching'
    #res = match(spec1, spec2, ts2ms('00:10:20,005'), ts2ms('00:10:22,743'), ts2ms('00:09:00,000'))
    print (CDM(t_slice(src_data, ts2ms('00:10:20,005'), ts2ms('00:10:22,743')), t_slice(dst_data, ts2ms('00:12:24,372'), ts2ms('00:12:27,110'))))

    #if not (res is None):
    #    print res, ms2ts(int(res[0])), ms2ts(int(res[1]))