Exemple #1
0
def auto_shift(snd_path, labels_path):
    '''
    自動ずれ補正
    '''

    snd = pausewave.open(snd_path, 'rb')
    labels = Labels(labels_path)

    if labels.dist_s == NO_DISTINCTION:
        return

    d = find_dist_s(snd)
    auto_shift_s = auto_shift_diff_s(d, labels.dist_s)

    if auto_shift_s != 0:
        labels.dist_s = d
        labels.shift(auto_shift_s)
        labels.write(labels_path)
        base_name = os.path.basename(snd_path)
        print 'auto shift: %.6fs %s' % (auto_shift_s, base_name)
Exemple #2
0
    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