Skip to content

Commit

Permalink
fix empty utterances (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Chaigneau authored Oct 9, 2023
1 parent 110b3d6 commit a9c85ef
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/wordcab_transcribe/services/post_processing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,26 @@ def final_processing_before_returning(
Returns:
List[Utterance]:
List of utterances with final processing.
List of utterances after final processing.
"""
if offset_start is not None:
offset_start = float(offset_start)
else:
offset_start = 0.0

final_utterances = []
for utterance in utterances:
utterance.text = format_punct(utterance.text)
utterance.start = convert_timestamp(
(utterance.start + offset_start), timestamps_format
)
utterance.end = convert_timestamp(
(utterance.end + offset_start), timestamps_format
)
utterance.words = utterance.words if word_timestamps else None
# Check if the utterance is not empty
if utterance.text.strip():
utterance.text = format_punct(utterance.text)
utterance.start = convert_timestamp(
(utterance.start + offset_start), timestamps_format
)
utterance.end = convert_timestamp(
(utterance.end + offset_start), timestamps_format
)
utterance.words = utterance.words if word_timestamps else None

return utterances
final_utterances.append(utterance)

return final_utterances

0 comments on commit a9c85ef

Please sign in to comment.