예제 #1
0
def _viterbiDecode(mfcc, bich_diar, thr_vit, wavFile, wdir, save_all):
    wavName = wavFile[:-4]
    vit_diar = viterbi.viterbi_decoding(mfcc, bich_diar, thr_vit)
    if save_all:
        vit_filename = os.path.join(wdir, wavName + '.d.seg')
        Diar.write_seg(vit_filename, vit_diar)
    return vit_diar
예제 #2
0
def _linearBic(mfcc, seg_diar, thr_l, wavFile, wdir, save_all):
    wavName = wavFile[:-4]
    bicl_diar = segmentation.bic_linear(mfcc, seg_diar, thr_l, sr=False)
    if save_all:
        bicl_filename = os.path.join(wdir, wavName + '.l.seg')
        Diar.write_seg(bicl_filename, bicl_diar)
    return bicl_diar
예제 #3
0
def _initialSegmentation(mfcc, wavFile, save_all, wdir):
    wavName = wavFile[:-4]
    init_diar = segmentation.init_seg(mfcc, wavName)
    if save_all:
        init_filename = os.path.join(wdir, wavName + '.i.seg')
        Diar.write_seg(init_filename, init_diar)
    return init_diar
예제 #4
0
def _gaussDiverSegmentation(mfcc, wavFile, init_diar, win_size, wdir, save_all):
    wavName = wavFile[:-4]
    seg_diar = segmentation.segmentation(mfcc, init_diar, win_size)
    if save_all:
        seg_filename = os.path.join(wdir, wavName + '.s.seg')
        Diar.write_seg(seg_filename, seg_diar)
    return seg_diar
예제 #5
0
def _bicAhc(mfcc, bicl_diar, thr_h, wavFile, wdir, save_all):
    wavName = wavFile[:-4]
    bic = hac_bic.HAC_BIC(mfcc, bicl_diar, thr_h, sr=False)
    bich_diar = bic.perform(to_the_end=True)
    if save_all:
        bichac_filename = os.path.join(wdir, wavName + '.h.seg')
        Diar.write_seg(bichac_filename, bich_diar)
    #link, data = plot_dendrogram(bic.merge, 0)
    return bich_diar
예제 #6
0
 def create_seg_viterbi(self, cep, segment_dir):
     #viterbi resegmentation
     for file_name in os.listdir(segment_dir):
         diar = Diar.read_seg(os.path.join(segment_dir, file_name))
         vit_diar = viterbi.viterbi_decoding(cep, diar, self.vit_penalty)
         Diar.write_seg(
             os.path.join(self.results_vit_dir,
                          file_name + '.viterbi.{:.2f}'.format(-250)),
             vit_diar)
예제 #7
0
 def create_seg_bic_hac(self, cep, segment_dir):
     for file_name in os.listdir(segment_dir):
         try:
             diar = Diar.read_seg(os.path.join(segment_dir, file_name))
             for bic_value in np.linspace(self.bic_hac_start,
                                          self.bic_hac_end,
                                          self.bic_hac_num):
                 bic = hac_bic.HAC_BIC(cep, diar, bic_value, sr=False)
                 bic_hac_diar = bic.perform(to_the_end=True)
                 Diar.write_seg(os.path.join(self.bic_hac_dir, file_name+'.bic_value.{:.2f}'.format(bic_value))\
                             , bic_hac_diar)
         except Exception as e:
             traceback.print_exc()
             continue
예제 #8
0
    def train(self):
        try:
            init_diar = Diar.read_seg(self.input_seg)
            #init_diar = segmentation.self.init_seg(cep, show)
            init_diar.pack(50)
            Diar.write_seg(self.init_seg, init_diar)
            gd_diar = segmentation.segmentation(self.cep, init_diar,
                                                self.win_size)
            Diar.write_seg(self.gd_seg, gd_diar)
        except Exception as e:
            traceback.print_exec()
            print("initialziation fault")

        #performing experiment
        self.create_seg_bic_linear(self.cep, gd_diar)
        self.create_seg_bic_hac(self.cep, self.linear_bic_dir)
        self.create_seg_iv_AHC(self.bic_hac_dir, self.input_show)
        self.create_seg_viterbi(self.cep, self.hac_iv_dir)
예제 #9
0
 def create_seg_iv_AHC(self, segment_dir, input_show):
     model_iv = ModelIV(self.model_fn)
     #print(segment_dir)
     for file_name in os.listdir(segment_dir):
         try:
             segment_diar = Diar.read_seg(
                 os.path.join(segment_dir, file_name))
             #print(segment_diar)
             model = self.train_ivectors(model_iv, self.mfcc_dir, file_name,
                                         segment_diar, self.input_show)
             scores = self.score_plda(model)
             for hac_value in np.linspace(self.t_min, self.t_max,
                                          self.t_num):
                 diar_iv, _, _ = hac_iv(segment_diar,
                                        scores,
                                        threshold=hac_value)
                 Diar.write_seg(os.path.join(self.hac_iv_dir, file_name+'.hac_value.{:.2f}'.format(hac_value))\
                             , diar_iv)
         except Exception as e:
             traceback.print_exc()
             print("There is an error over here")
             continue
예제 #10
0
 def create_seg_bic_linear(self, cep, diar):
     for t1 in np.linspace(self.li_bic_p_start, self.li_bic_p_stop,
                           self.li_bic_p_num):
         bicl_diar = segmentation.bic_linear(cep, diar, t1, sr=False)
         Diar.write_seg(self.linear_bic_seg.format(t1), bicl_diar)