Skip to content

Commit f9d3399

Browse files
committed
feat: add custom dictionary corrections
1 parent c0da115 commit f9d3399

10 files changed

Lines changed: 1167 additions & 23 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ log = "0.4"
1717
nix = { version = "0.29", features = ["signal"] }
1818
serde = { version = "1", features = ["derive"] }
1919
toml = "0.8"
20+
unicode-segmentation = "1"
2021

2122
[target.'cfg(target_os = "linux")'.dependencies]
2223
evdev = { version = "0.13", features = ["tokio"] }
@@ -59,7 +60,7 @@ objc2-app-kit = { version = "0.2", features = [
5960
"NSBox",
6061
"NSUserInterfaceLayout",
6162
] }
62-
objc2-foundation = { version = "0.2", features = ["NSString", "NSArray", "NSThread", "NSTimer", "NSDate", "NSGeometry"] }
63+
objc2-foundation = { version = "0.2", features = ["NSString", "NSArray", "NSData", "NSThread", "NSTimer", "NSDate", "NSGeometry"] }
6364

6465
[dev-dependencies]
6566
tempfile = "3"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Installs the matching `.rpm` / `.deb`, fetches the model, and starts the user se
3232
## Docs
3333

3434
- [Install](docs/INSTALL.md) — requirements, manual package install, from source, verify.
35-
- [Configuration](docs/CONFIGURATION.md)`config.toml`, env vars, PTT-key aliases, recording indicator.
35+
- [Configuration](docs/CONFIGURATION.md)`config.toml`, custom dictionary corrections, env vars, PTT-key aliases, recording indicator.
3636
- [Architecture](docs/ARCHITECTURE.md) — daemon/watcher on Linux, single-process on macOS.
3737
- [Troubleshooting](docs/TROUBLESHOOTING.md)
3838
- [Uninstall](docs/UNINSTALL.md)

docs/CONFIGURATION.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
The basics — hold-to-talk, default key, changing the key — are in the [README quickstart](../README.md#quickstart). This page is the full reference: config file format, env var overrides, the PTT-key alias table, the recording indicator, and how services are laid out on Linux.
3+
The basics — hold-to-talk, default key, changing the key — are in the [README quickstart](../README.md#quickstart). This page is the full reference: config file format, custom dictionary corrections, env var overrides, the PTT-key alias table, the recording indicator, and how services are laid out on Linux.
44

55
## Config file
66

@@ -34,21 +34,66 @@ auto_paste = true
3434
# a single pasteboard and the auto-paste flow already uses it.
3535
write_clipboard = false
3636

37+
# macOS: restore the previous clipboard contents after auto-pasting.
38+
# false = leave dictated text in the clipboard after paste.
39+
restore_clipboard_after_paste = true
40+
3741
# Drop fillers (uh, um, er, ah, erm, hmm) and collapse stuttered
3842
# repetitions (`I I I think` → `I think`).
3943
filter_filler_words = true
4044
```
4145

46+
## Custom dictionary
47+
48+
utter's dictionary is a separate TOML file for correcting repeated
49+
speech-to-text mistakes. It is local-only and is reloaded on the next dictation,
50+
so dictionary edits do not require restarting utter.
51+
52+
- Linux: `~/.config/utter/dictionary.toml`
53+
- macOS: `~/Library/Application Support/utter/dictionary.toml`
54+
55+
Use the CLI on either platform:
56+
57+
```bash
58+
utter dictionary add LUFS --replace luffs
59+
utter dictionary add AcmeCloud --replace "acme cloud" --replace "acme clout"
60+
utter dictionary list
61+
utter dictionary remove LUFS
62+
utter dictionary path
63+
```
64+
65+
Dictionary file format:
66+
67+
```toml
68+
version = 1
69+
70+
[[entries]]
71+
term = "LUFS"
72+
replace = ["luffs"]
73+
74+
[[entries]]
75+
term = "AcmeCloud"
76+
replace = ["acme cloud", "acme clout"]
77+
```
78+
79+
`term` is pasted exactly as written, including casing and punctuation. Each
80+
`replace` phrase is a heard-as transcription that should be rewritten to
81+
`term`; at least one `--replace` phrase is required when adding an entry.
82+
Matching is case-insensitive, Unicode-aware, phrase-boundary-aware, and
83+
non-recursive. Terms and replacement phrases are limited to 60 displayed
84+
characters.
85+
4286
## Env var overrides
4387

4488
Every field above is overridable at runtime via an environment variable with the same name, upper-cased and prefixed `UTTER_` — e.g. `UTTER_AUTO_PASTE=0` wins over `auto_paste = true` in the file. Useful for one-off runs (`UTTER_AUTO_PASTE=0 utter daemon`) or systemd-drop-in tweaks without editing the file:
4589

46-
| Env var | Values | Overrides field | Purpose |
47-
|-----------------------------|-----------|-----------------------|-------------------------------------------------------------------------|
48-
| `UTTER_KEY` | name/code | `key` | PTT key. |
49-
| `UTTER_AUTO_PASTE` | `0` / `1` | `auto_paste` | Synthesize the paste shortcut. |
50-
| `UTTER_WRITE_CLIPBOARD` | `0` / `1` | `write_clipboard` | Also write the regular clipboard (Linux only). |
51-
| `UTTER_FILTER_FILLER_WORDS` | `0` / `1` | `filter_filler_words` | Drop fillers (uh/um/er/ah/erm/hmm), collapse stutters. |
90+
| Env var | Values | Overrides field | Purpose |
91+
|----------------------------------------|-----------|-----------------------------------|-------------------------------------------------------------------------|
92+
| `UTTER_KEY` | name/code | `key` | PTT key. |
93+
| `UTTER_AUTO_PASTE` | `0` / `1` | `auto_paste` | Synthesize the paste shortcut. |
94+
| `UTTER_WRITE_CLIPBOARD` | `0` / `1` | `write_clipboard` | Also write the regular clipboard (Linux only). |
95+
| `UTTER_RESTORE_CLIPBOARD_AFTER_PASTE` | `0` / `1` | `restore_clipboard_after_paste` | Restore previous clipboard contents after macOS auto-paste. |
96+
| `UTTER_FILTER_FILLER_WORDS` | `0` / `1` | `filter_filler_words` | Drop fillers (uh/um/er/ah/erm/hmm), collapse stutters. |
5297

5398
These stay env-only (third-party tools, not utter's config):
5499

0 commit comments

Comments
 (0)