aadnk commited on
Commit
ab69310
1 Parent(s): 9cae71a

Fix preprocessor when words are disabled

Browse files
Files changed (1) hide show
  1. src/utils.py +9 -8
src/utils.py CHANGED
@@ -105,16 +105,17 @@ def __subtitle_preprocessor_iterator(transcript: Iterator[dict], maxLineWidth: i
105
  words = segment.get('words', [])
106
 
107
  if len(words) == 0:
108
- # Yield the segment as-is
109
  if maxLineWidth is None or maxLineWidth < 0:
110
  yield segment
111
-
112
- # Yield the segment with processed text
113
- yield {
114
- 'start': segment['start'],
115
- 'end': segment['end'],
116
- 'text': process_text(segment['text'].strip(), maxLineWidth)
117
- }
 
118
 
119
  subtitle_start = segment['start']
120
  subtitle_end = segment['end']
 
105
  words = segment.get('words', [])
106
 
107
  if len(words) == 0:
108
+ # Yield the segment as-is or processed
109
  if maxLineWidth is None or maxLineWidth < 0:
110
  yield segment
111
+ else:
112
+ yield {
113
+ 'start': segment['start'],
114
+ 'end': segment['end'],
115
+ 'text': process_text(segment['text'].strip(), maxLineWidth)
116
+ }
117
+ # We are done
118
+ continue
119
 
120
  subtitle_start = segment['start']
121
  subtitle_end = segment['end']