def find(self, sil_lv, sil_dur, before_dur, after_dur): if self._vol is None: return self.lm.save() self.lm.labels = find_sound(self._vol, sil_lv, sil_dur, before_dur, after_dur) self.UpdateDrawing(2) self.post_label_change_evt()
def __init__(self): wx.Frame.__init__(self, None, size=(500, 400)) wav = pausewave.open('in.mp3') vol = Volume(wav) labels = find_sound(vol) win = LabelsWindow(parent=self, id=-1) self.statusbar = self.CreateStatusBar() win.Bind(EVT_VW_POS_CHANGE, self.OnVwPosChange) win.Bind(EVT_REQ_PLAY, self.OnPlay) win.Bind(EVT_REQ_PAUSE, self.OnPause) win.Bind(EVT_REQ_IFCUT_PLAY, self.OnIfCutPlay) win.Bind(EVT_REQ_PAUSE_PLAY, self.OnPausePlay) win.SetVolume(vol) win.SetLabels(labels, None) self.win = win
def find_dist_s(snd): ''' 特徴となる位置の最初の1つを返す。 見つからなければ NO_DISTINCTION ''' vol = Volume(snd, DISTINCTION_RATE) labels = find_sound(vol, 5, 0.3, 0, 0) if len(labels) == 1: avg0 = (labels[0].start_s + labels[0].end_s) / 2 return avg0 elif len(labels) > 1: avg0 = (labels[0].start_s + labels[0].end_s) / 2 avg1 = (labels[1].start_s + labels[1].end_s) / 2 avg = (avg0 + avg1) / 2 return avg else: return NO_DISTINCTION
def LoadLabels(self, f, snd): ''' ラベル情報ファイルを読み込む。なければ作成する ''' if os.path.exists(f): labels = Labels(f) else: sil_lv = self.conf.sil_lv sil_dur = self.conf.sil_dur_s before_dur = self.conf.before_dur_s after_dur = self.conf.after_dur_s vol = Volume(snd, FIND_RATE) labels = find_sound(vol, sil_lv, sil_dur, before_dur, after_dur) labels.write(f) if not hasattr(labels, 'dist_s') or labels.dist_s == NO_DISTINCTION: labels.dist_s = find_dist_s(snd) labels.write(f) return labels