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
+10 -5
View File
@@ -59,22 +59,27 @@ def model(conf):
return conf["cleanup_model"]
def run(text, conf, system_prompt, timeout=180):
"""Hand the transcript to whoever is set to clean it up."""
def run(text, conf, system_prompt, timeout=180, aborter=None):
"""Hand the transcript to whoever is set to clean it up.
`aborter` is only of use to the two that answer over HTTP; a CLI is stopped
between blocks instead, which is close enough when a block is seconds.
"""
name = provider(conf)
if name == "openrouter":
return api.cleanup(
text, conf.openrouter_key(), conf["cleanup_model"], system_prompt,
reasoning=conf["cleanup_reasoning"],
base_url=conf["openrouter_base_url"], timeout=timeout,
aborter=aborter,
)
if name == "local":
return _local(text, conf, system_prompt, timeout)
return _local(text, conf, system_prompt, timeout, aborter)
runner = _claude if name == "claude" else _codex
return runner(text, conf, system_prompt, timeout)
def _local(text, conf, system_prompt, timeout):
def _local(text, conf, system_prompt, timeout, aborter=None):
"""llama.cpp, on this machine, answering the request OpenRouter answers.
No key and no bill, and the address does not exist until the server is up,
@@ -88,7 +93,7 @@ def _local(text, conf, system_prompt, timeout):
reasoning=conf["local_llm_reasoning"],
base_url=api.serving(ggml.llm),
timeout=max(timeout, api.LOCAL_TIMEOUT),
provider="local-llm", service=service,
provider="local-llm", service=service, aborter=aborter,
)
except api.ApiError as exc:
# A server that died mid-request would otherwise report only that the