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
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)
def pyAudioDiar(): duration, result = aS.speaker_diarization(labelFileNameSound.get(), int(labelNumberOfSpeakers.get()), lda_dim=0, plot_res=False) show = 'diarizationExample' input_show = labelFileNameSound.get() input_sad = None win_size = 250 thr_l = 2 thr_h = 3 thr_vit = -250 wdir = os.path.join('out', show) if not os.path.exists(wdir): os.makedirs(wdir) fs = get_feature_server(input_show, feature_server_type='basic') cep, _ = fs.load(show) cep.shape if input_sad is not None: init_diar = Diar.read_seg(input_sad) init_diar.pack(50) else: init_diar = segmentation.init_seg(cep, show) seg_diar = segmentation.segmentation(cep, init_diar, win_size) bicl_diar = segmentation.bic_linear(cep, seg_diar, thr_l, sr=False) bic = hac_bic.HAC_BIC(cep, bicl_diar, thr_h, sr=False) bich_diar = bic.perform(to_the_end=True) vit_diar = viterbi.viterbi_decoding(cep, bich_diar, thr_vit) resList = [] currentPosition = 0 for row in vit_diar: speakerValue = int(row[1][1:]) while currentPosition < (row[3] + row[4]): resList.append(speakerValue) currentPosition += 20 currentPosition = 0 realityList = [] realityFile = pd.read_csv(labelFileNameSegment.get(), delimiter='\t', encoding='utf-8', names=['start', 'end', 'speaker']) for index, row in realityFile.iterrows(): speakerValue = int(row['speaker'][1:]) while currentPosition < row['end']: realityList.append(int(speakerValue)) currentPosition += 0.2 plot.subplot(3, 1, 2) plot.title("s4d:") plot.plot(np.arange(0, duration, duration / len(resList)), resList, 'ro') plot.subplot(3, 1, 1) plot.title("Реальность:") plot.plot(np.arange(0, duration, duration / len(realityList)), realityList, 'bo') plot.subplot(3, 1, 3) plot.title("pyPlotAudio:") plot.plot(np.arange(0, duration, duration / len(result)), result, 'go') plot.show()
def _gaussDiverSegmentation(mfcc, init_diar, win_size): return segmentation.segmentation(mfcc, init_diar, win_size)