Skip to content

Commit

Permalink
Fixed errors in the CTM gen functions (NVIDIA#8416) (NVIDIA#8420)
Browse files Browse the repository at this point in the history
Signed-off-by: Taejin Park <[email protected]>
Co-authored-by: Taejin Park <[email protected]>
Signed-off-by: Sasha Meister <[email protected]>
  • Loading branch information
2 people authored and sashameister committed Feb 15, 2024
1 parent ad6a884 commit 5b8b5c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/speaker_tasks/create_alignment_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def get_seg_info_from_ctm_line(
"""
Get time stamp information and speaker labels from CTM lines.
This is following CTM format appeared in `Rich Transcription Meeting Eval Plan: RT09` document.
CTM Format:
<SOURCE>< <CHANNEL> <BEG-TIME> <DURATION> <TOKEN> <CONF> <TYPE> <SPEAKER>
Args:
ctm_list (list): List containing CTM items. e.g.: ['sw02001-A', '1', '0.000', '0.200', 'hello', '0.98', 'lex', 'speaker3']
output_precision (int): Precision for CTM outputs in integer.
Expand All @@ -47,6 +50,8 @@ def get_seg_info_from_ctm_line(
end = float(ctm_list[start_time_index]) + float(ctm_list[duration_index])
start = round(start, output_precision)
end = round(end, output_precision)
if type(speaker_id) == str:
speaker_id = speaker_id.strip()
return start, end, speaker_id


Expand Down Expand Up @@ -106,7 +111,7 @@ def create_new_ctm_entry(session_name, speaker_id, wordlist, alignments, output_
start_time=align1,
duration=align2,
token=word,
conf=0,
conf=None,
type_of_token='lex',
speaker=speaker_id,
output_precision=output_precision,
Expand Down Expand Up @@ -245,7 +250,7 @@ def create_manifest_with_alignments(
prev_end = 0
for i in range(len(lines)):
ctm = lines[i].split(' ')
speaker_id, start, end = get_seg_info_from_ctm_line(ctm_list=ctm, output_precision=output_precision)
start, end, speaker_id = get_seg_info_from_ctm_line(ctm_list=ctm, output_precision=output_precision)
interval = start - prev_end

if (i == 0 and interval > 0) or (i > 0 and interval > silence_dur_threshold):
Expand Down

0 comments on commit 5b8b5c1

Please sign in to comment.