@@ -286,10 +286,46 @@ def test_transcription_worker_calls_stable_whisper(self, qtbot: QtBot, transcrip
286286 finished_spy .assert_called_once ()
287287 emitted_segments = finished_spy .call_args [0 ][0 ]
288288 assert len (emitted_segments ) == 1
289- assert emitted_segments [0 ].start == 100
290- assert emitted_segments [0 ].end == 200
289+ assert emitted_segments [0 ].start == 1000
290+ assert emitted_segments [0 ].end == 2000
291291 assert emitted_segments [0 ].text == "Hello"
292292
293+ def test_transcription_worker_merges_segments_closer_than_gap (
294+ self , qtbot : QtBot , transcription_dao , transcription_segment_dao , transcription_service
295+ ):
296+ id = uuid .uuid4 ()
297+ transcription_dao .insert (
298+ Transcription (
299+ id = str (id ),
300+ status = "completed" ,
301+ file = test_audio_path ,
302+ task = Task .TRANSCRIBE .value ,
303+ model_type = ModelType .WHISPER .value ,
304+ whisper_model_size = WhisperModelSize .TINY .value ,
305+ )
306+ )
307+ # 150 ms apart, below the 0.2 s merge gap
308+ transcription_segment_dao .insert (TranscriptionSegment (40 , 1000 , "Bien." , "" , str (id )))
309+ transcription_segment_dao .insert (TranscriptionSegment (1150 , 2000 , "Venue." , "" , str (id )))
310+
311+ mock_transcription_options = MagicMock ()
312+ mock_transcription_options .extract_speech = False
313+ worker = TranscriptionWorker (
314+ transcription = transcription_dao .find_by_id (str (id )),
315+ transcription_options = mock_transcription_options ,
316+ transcription_service = transcription_service ,
317+ regroup_string = "mg=0.2" ,
318+ )
319+ finished_spy = MagicMock ()
320+ worker .finished .connect (finished_spy )
321+
322+ worker .run ()
323+
324+ emitted_segments = finished_spy .call_args [0 ][0 ]
325+ assert len (emitted_segments ) == 1
326+ assert emitted_segments [0 ].start == 40
327+ assert emitted_segments [0 ].end == 2000
328+
293329 # TODO - Fix this test on Windows, should work.
294330 # Possibly the `on_loop_toggle_changed` gets triggered on setChecked
295331 @pytest .mark .skipif (sys .platform .startswith ("win" ), reason = "Skipping on Windows" )
0 commit comments