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
+26 -1
View File
@@ -512,6 +512,10 @@ class SettingsWindow(QDialog):
self.meetings.finished.connect(self._on_minutes_finished)
self.meetings.failed.connect(self._on_minutes_failed)
self._load()
# Connected after the load, so that filling the boxes in is not taken
# for the user ticking them.
self.file_timestamps.toggled.connect(self._remember_file_choices)
self.file_cleanup.toggled.connect(self._remember_file_choices)
# On a machine where nothing can transcribe yet, this window was opened
# because of that, so open it on the tab that fixes it.
if not conf.transcribe_ready():
@@ -1159,7 +1163,7 @@ class SettingsWindow(QDialog):
self.file_run = QPushButton(t("Transcribe"))
self.file_run.clicked.connect(self._run_file)
self.file_stop = QPushButton(t("Stop"))
self.file_stop.clicked.connect(self.transcriber.stop)
self.file_stop.clicked.connect(self._stop_file)
self.file_stop.setEnabled(False)
run_row = QHBoxLayout()
run_row.addWidget(self.file_run)
@@ -1713,6 +1717,20 @@ class SettingsWindow(QDialog):
self.file_path = path
self.file_label.setText(os.path.basename(path))
self.conf["file_last_dir"] = os.path.dirname(path)
self._remember_file_choices()
def _remember_file_choices(self):
"""Keep this tab's choices without waiting for the Save button.
The two switches and the folder belong to the run rather than to the
form: what was ticked before Transcribe is what the next file wants
too, and Save is at the far end of a window opened to transcribe one
file. Everything else on the tab is a button, so there is nothing here
an unsaved form could be caught by.
"""
self.conf["file_timestamps"] = self.file_timestamps.isChecked()
self.conf["file_cleanup"] = self.file_cleanup.isChecked()
self.conf.save()
def _run_file(self):
if not getattr(self, "file_path", "") or self.transcriber.busy:
@@ -1728,6 +1746,13 @@ class SettingsWindow(QDialog):
self.file_cleanup.isChecked(),
)
def _stop_file(self):
# The button goes dead here rather than when the run comes back, so a
# second press cannot land while the first one is still travelling.
self.file_stop.setEnabled(False)
self.file_status.setText(t("Stopping…"))
self.transcriber.stop()
def _on_file_progress(self, message):
self.file_status.setText(message)
if message == t("Stopped."):