romsyflux commited on
Commit
1479f5d
1 Parent(s): 1a63d5a

Fix for no_end_timestamp

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -175,20 +175,27 @@ def merge_segments(segments):
175
  def align_timestamps(segments, dia_seg_last_end):
176
  aligned_segments = []
177
  previous_end = 0.0
 
178
 
179
  for segment in segments:
180
  start, end = segment['timestamp']
 
 
181
  if start < previous_end:
182
- end -= start
183
- start += previous_end
184
- end += previous_end
185
-
 
 
 
 
186
  if end == None:
187
  end = dia_seg_last_end
188
 
189
  aligned_segments.append({'timestamp': (start, end), 'text': segment['text']})
190
  previous_end = end
191
-
192
  return aligned_segments
193
 
194
  def transcribe_diarize(audio):
 
175
  def align_timestamps(segments, dia_seg_last_end):
176
  aligned_segments = []
177
  previous_end = 0.0
178
+ previous_end_before_align = 0.0
179
 
180
  for segment in segments:
181
  start, end = segment['timestamp']
182
+ lenght = end - start
183
+ adjust = 0.0
184
  if start < previous_end:
185
+ if start == 0.0:
186
+ start += previous_end
187
+ end += previous_end
188
+ adjust += previous_end
189
+ else:
190
+ start += previous_end - previous_end_before_align
191
+ end += previous_end - previous_end_before_align
192
+ adjust += previous_end - previous_end_before_align
193
  if end == None:
194
  end = dia_seg_last_end
195
 
196
  aligned_segments.append({'timestamp': (start, end), 'text': segment['text']})
197
  previous_end = end
198
+ previous_end_before_align = end - adjust
199
  return aligned_segments
200
 
201
  def transcribe_diarize(audio):