Example #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
Example #2
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)
Example #3
0
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()
Example #4
0
def _viterbiDecode(mfcc, bich_diar, thr_vit):
    return viterbi.viterbi_decoding(mfcc, bich_diar, thr_vit)