dictation_history
dictation_history
¶
A local, bounded history of dictations.
Two things make this worth having: you can recover a sentence the paste lost (wrong window focused, app ate it), and you can see what the recogniser actually heard — which is how you find out that "small" fixes the proper nouns "base" was mangling.
Design constraints that follow from the privacy contract:
- Local only. A JSONL file under the Diapason config dir. Nothing here is ever sent anywhere; the outbound ratchet has no reason to see this module.
- Opt-out and bounded. Off by default is wrong (an invisible history is the point of a history), but unbounded growth is a liability: a dictation tool used all day would accumulate every sentence you ever spoke. It keeps the last N entries, N being small enough to stay a convenience rather than an archive.
- Content lives here, so nowhere else. Entries hold the transcript in
clear — that IS the feature — which is precisely why the log must not.
redactstays the rule for logging; this file is the one sanctioned place the text is written down.
Classes¶
DictationEntry
dataclass
¶
DictationEntry(
text: str,
timestamp: float,
duration_s: float = 0.0,
app: str = "",
model: str = "",
chars: int = 0,
pid: int = 0,
)
One completed dictation.
Functions:¶
load_history
¶
load_history(
path: str | Path | None = None,
*,
limit: Optional[int] = None,
) -> List[DictationEntry]
Return entries, newest first. A corrupt line is skipped, not fatal.
Source code in src/diapason/desktop/dictation_history.py
append_entry
¶
append_entry(
entry: DictationEntry,
*,
path: str | Path | None = None,
max_entries: int = DEFAULT_MAX_ENTRIES,
) -> None
Append one entry, trimming the file to max_entries.
Never raises: losing a history line must not break a dictation that otherwise succeeded.
Source code in src/diapason/desktop/dictation_history.py
clear_history
¶
Delete the history file. Returns True if one existed.
Source code in src/diapason/desktop/dictation_history.py
stats
¶
stats(entries: Iterable[DictationEntry]) -> dict
Aggregate a few honest numbers for a dashboard.
Words-per-minute is deliberately absent: it would need a speaking-time denominator this data cannot support, and a made-up productivity figure is worse than none.