Make the audio file tab remember, and its Stop stop

The two switches were written to disk by the Save button at the far end of
the window, so a file transcribed with timestamps and cleanup was
transcribed without either the next time. They belong to the run rather than
to the form: they go to disk as they are ticked now, and the folder the last
file came from goes with them.

Stop only set a flag that was looked at between chunks, and a file under ten
minutes is one chunk, so for most files it was looked at after the work it
was meant to stop had already finished. Nothing that blocks is reached by a
flag. The request is inside urlopen, ffmpeg is inside communicate, and a
whisper on this machine is a process of ours that would grind on to the end
of the chunk with nobody left to hand the answer to. So the socket is shut
down under the read, ffmpeg is killed, and a local server is stopped and
left for the next run to start again.

Shutting the socket down rather than closing it is the point: close() alone
leaves a thread already inside recv() waiting for bytes that are never
coming now. The connection is registered before it has a socket, so a stop
landing in the few lines between making a connection and blocking on it
refuses the connection rather than missing it and letting urllib quietly
open another.
This commit is contained in:
yusufipk
2026-08-02 09:29:12 +03:00
parent fc333fcb8c
commit 7a507c52eb
7 changed files with 438 additions and 33 deletions
+37
View File
@@ -266,6 +266,43 @@ class Settings(DikteTest):
window = self.window(cfg.Config())
self.assertEqual(window.windowTitle(), "Dikte Ayarları")
def test_the_audio_file_switches_are_kept_without_the_save_button(self):
"""They are ticked to transcribe one file, not to fill in a form."""
self.write_config({"file_timestamps": False, "file_cleanup": True})
window = self.window(cfg.Config())
window.file_timestamps.setChecked(True)
window.file_cleanup.setChecked(False)
stored = self.read_config_file()
self.assertTrue(stored["file_timestamps"])
self.assertFalse(stored["file_cleanup"])
def test_loading_the_audio_file_tab_is_not_taken_for_a_change(self):
self.write_config({"file_timestamps": True, "file_cleanup": False})
conf = cfg.Config()
with mock.patch.object(conf, "save") as save:
window = self.window(conf)
save.assert_not_called()
self.assertTrue(window.file_timestamps.isChecked())
self.assertFalse(window.file_cleanup.isChecked())
def test_the_run_button_comes_back_when_the_stop_lands(self):
"""In whichever language, since the worker says so through t() too."""
for language in ("auto", "tr"):
with self.subTest(language=language):
self.write_config({"ui_language": language})
window = self.window(cfg.Config())
window.file_run.setEnabled(False)
window._on_file_progress(settings_ui.t("Stopped."))
self.assertTrue(window.file_run.isEnabled())
def test_stop_leaves_nothing_to_press_twice(self):
window = self.window(cfg.Config())
with mock.patch.object(window.transcriber, "stop") as stop:
window.file_stop.setEnabled(True)
window._stop_file()
stop.assert_called_once_with()
self.assertFalse(window.file_stop.isEnabled())
class Overlay(DikteTest):
def overlay(self, **kwargs):