Skip to content

Commit

Permalink
fix: bug of None text on consecutive missing timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudAshraf97 committed Oct 15, 2023
1 parent 71f6a74 commit 570807e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Whisper_Transcription_+_NeMo_Diarization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
" for i, ws in enumerate(word_timestamps[1:], start=1):\n",
" # if ws doesn't have a start and end\n",
" # use the previous end as start and next start as end\n",
" if ws.get(\"start\") is None:\n",
" if ws.get(\"start\") is None and ws.get(\"word\") is not None:\n",
" ws[\"start\"] = word_timestamps[i - 1][\"end\"]\n",
" ws[\"end\"] = _get_next_start_timestamp(word_timestamps, i)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def filter_missing_timestamps(word_timestamps):
for i, ws in enumerate(word_timestamps[1:], start=1):
# if ws doesn't have a start and end
# use the previous end as start and next start as end
if ws.get("start") is None:
if ws.get("start") is None and ws.get("word") is not None:
ws["start"] = word_timestamps[i - 1]["end"]
ws["end"] = _get_next_start_timestamp(word_timestamps, i)

Expand Down

0 comments on commit 570807e

Please sign in to comment.