feat(recognition): add custom dictionary support - #767
Conversation
✅ Deploy Preview for voca-linux canceled.
|
|
Thanks @GrahamJenkins. A maintainer will review it. |
|
| Filename | Overview |
|---|---|
| src/vocalinux/dictionary_manager.py | Implements live dictionary loading, path and status handling, prompt limits, and safe malformed-UTF-8 behavior. |
| src/vocalinux/speech_recognition/recognition_manager.py | Injects refreshed dictionary prompts into Whisper and whisper.cpp and emits a one-time VOSK incompatibility warning. |
| src/vocalinux/ui/settings_dialog.py | Adds typed dictionary settings controls, session-override locking, and live status refresh. |
| src/vocalinux/main.py | Adds the session-only dictionary CLI override and wires the dictionary manager into recognition. |
| tests/test_dictionary_manager.py | Covers live reloads, malformed UTF-8, prompt composition and clearing, transient configuration, and VOSK behavior. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as CLI / Settings
participant DM as DictionaryManager
participant RM as RecognitionManager
participant Engine as Whisper Engine
User->>CLI: Configure or override dictionary path
CLI->>DM: Create/update dictionary configuration
RM->>DM: Build prompt before transcription
DM->>DM: Re-read UTF-8 dictionary file
DM-->>RM: Current terms or no prompt
RM->>Engine: Transcribe with composed prompt
Engine-->>User: Recognized text
Reviews (2): Last reviewed commit: "fix(dictionary): handle invalid UTF-8 sa..." | Re-trigger Greptile
| @@ -3568,6 +3572,98 @@ def _on_close_clicked(self, button): | |||
| """Close the dialog through the normal response path (same as title-bar X).""" | |||
There was a problem hiding this comment.
Dictionary signatures lack type hints
The new dictionary UI methods and callbacks omit parameter or return annotations, expanding the untyped interface surface contrary to the repository requirement that every function signature include type hints. The same pattern also appears in the new dictionary test helpers.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed in 90ba737. The new Dictionary settings handlers and test helpers now have explicit type annotations.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
Adds custom dictionary support using a UTF-8 text file with one term or phrase per line.
~/.config/vocalinux/dictionary.txtby default.--dictionary-file PATHoverride without modifyingconfig.json.The accessibility scanner discussed separately is intentionally not included in this PR.
Related Discussion
#483
Type of Change
Verification
git diff --checkpass.The full local test run is environment-limited: an existing IBus test cannot bind its Unix socket in the sandbox after 551 tests pass, and an installer Vulkan test later times out. The focused feature suite passes and upstream CI remains the final full-suite check.
Checklist
Additional Notes
The custom dictionary is disabled by default. For whisper.cpp, the existing Advanced initial prompt remains first and dictionary terms are appended after it.