Skip to content

Commit

Permalink
Handling <end-time> of -1 in the segments file (#952)
Browse files Browse the repository at this point in the history
Update kaldi.py to support <end-time> equal to -1 in segment file.
  • Loading branch information
JinZr authored Jan 30, 2023
1 parent 18b82e2 commit 8d7906e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lhotse/kaldi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ def fix_id(t: str) -> str:
genders = load_kaldi_text_mapping(path / "spk2gender")
languages = load_kaldi_text_mapping(path / "utt2lang")

# to support <end-time> == -1 in segments file
# https://kaldi-asr.org/doc/extract-segments_8cc.html
# <end-time> of -1 means the segment runs till the end of the WAV file
supervision_set = SupervisionSet.from_segments(
SupervisionSegment(
id=fix_id(segment_id),
recording_id=recording_id,
start=float(start),
duration=add_durations(
float(end), -float(start), sampling_rate=sampling_rate
float(end) if end != "-1" else durations[recording_id],
-float(start),
sampling_rate=sampling_rate,
),
channel=0,
text=texts[segment_id],
Expand Down

0 comments on commit 8d7906e

Please sign in to comment.