Repair misheard words, surface cleanup failures, add a restart action

The cleanup prompt now asks the model to fix words the transcriber misheard
when the context makes the intended one clear, and to leave them alone when
it does not. Speech models fail phonetically on proper nouns, and that is
exactly what context can recover.

The names you enter for the transcription hint are handed to the cleanup
model as a glossary too. Knowing the spelling is what lets it recognise
"kuber netis" as Kubernetes.

A failed cleanup used to be almost invisible: the raw transcript was pasted
and a progress line flashed by, so a rejected key looked exactly like
working dictation for days. It now leaves the indicator amber with the
reason, sends a notification, and records the error in the history. HTTP
401, 402 and 429 are reported as what they are, naming the service.

Also:
- Settings can test the OpenRouter key, not just the OpenAI one
- Tray menu and CLI gained Restart, which re-execs in place
- Defaults saved into the config by older versions are recognised by their
  fingerprint and dropped, so an untouched prompt keeps getting improvements
- The IPC socket is user-only; Qt puts it in /tmp
This commit is contained in:
yusufipk
2026-07-25 19:51:32 +07:00
parent 011493a9bc
commit 60c8006725
9 changed files with 278 additions and 43 deletions
+8 -4
View File
@@ -21,7 +21,7 @@ CHUNK_SECONDS = audio.CHUNK_FRAMES / audio.RATE
class Pipeline(QObject):
stage = pyqtSignal(str) # human-readable progress line
finished = pyqtSignal(str, str) # raw transcript, final text
finished = pyqtSignal(str, str, str) # raw transcript, final text, warning
failed = pyqtSignal(str)
def __init__(self, conf, parent=None):
@@ -75,6 +75,7 @@ class Pipeline(QObject):
return
text = raw
warning = ""
if conf["cleanup_enabled"]:
self.stage.emit(t("Cleaning up…"))
try:
@@ -86,9 +87,11 @@ class Pipeline(QObject):
base_url=conf["openrouter_base_url"],
)
except api.ApiError as exc:
# A failed cleanup must not cost us the transcript.
# Keep the transcript, but never let the failure pass unseen:
# a rejected key would otherwise look like working dictation.
text = raw
self.stage.emit(t("Cleanup skipped: {error}", error=exc))
warning = str(exc)
print(f"dikte: cleanup failed: {exc}", file=sys.stderr)
previous = paste.read_clipboard() if conf["restore_clipboard"] else None
paste.copy(text)
@@ -106,11 +109,12 @@ class Pipeline(QObject):
"elapsed": round(time.monotonic() - started, 1),
"model": conf["transcribe_model"],
"cleanup_model": conf["cleanup_model"] if conf["cleanup_enabled"] else "",
"cleanup_error": warning,
"raw": raw,
"text": text,
})
cfg.trim_history(conf["history_limit"])
self.finished.emit(raw, text)
self.finished.emit(raw, text, warning)
except (api.ApiError, paste.PasteError) as exc:
print(f"dikte: {exc}", file=sys.stderr)