Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pyAudioAnalysis/audioSegmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,12 +1010,13 @@ def speaker_diarization(filename, n_speakers, mid_window=2.0, mid_step=0.2,
class_names = ["speaker{0:d}".format(c) for c in range(num_speakers)]

# load ground-truth if available
gt_file = filename.replace('.wav', '.segments')
# if groundtruth exists
if os.path.isfile(gt_file):
seg_start, seg_end, seg_labs = read_segmentation_gt(gt_file)
flags_gt, class_names_gt = segments_to_labels(seg_start, seg_end,
seg_labs, mid_step)
if '.wav' in filename:
gt_file = filename.replace('.wav', '.segments')
# if groundtruth exists
if os.path.isfile(gt_file):
seg_start, seg_end, seg_labs = read_segmentation_gt(gt_file)
flags_gt, class_names_gt = segments_to_labels(seg_start, seg_end,
seg_labs, mid_step)

if plot_res:
fig = plt.figure()
Expand All @@ -1028,7 +1029,7 @@ def speaker_diarization(filename, n_speakers, mid_window=2.0, mid_step=0.2,
ax1.set_yticklabels(class_names)
ax1.plot(np.array(range(len(cls))) * mid_step + mid_step / 2.0, cls)

if os.path.isfile(gt_file):
if '.wav' in filename and os.path.isfile(gt_file):
if plot_res:
ax1.plot(np.array(range(len(flags_gt))) *
mid_step + mid_step / 2.0, flags_gt, 'r')
Expand Down