Skip to content

text

This directory provides the logic and vocabulary required for natural dictation, auto-formatting, prose control, and phrase history in Talon. It contains grammar definitions, lists of vocabulary and formatters, and Python scripts that handle context-sensitive auto-spacing and capitalization.

Together, these files implement a robust dictation engine that intelligently formats spoken English into properly spaced, capitalized, and structured text.

Core Architecture

The text engine works by capturing spoken utterances, applying state-aware formatting rules (e.g., ensuring spaces are only added where punctuation rules dictate), and managing a history of typed utterances to facilitate corrections.

Spoken Text & Formatting Engine

  • text_and_dictation.py is the primary engine behind dictation. It defines Talon captures such as <user.text>, <user.prose>, and <user.raw_prose> which translate spoken words into strings. It contains the DictationFormat class, which handles:
    • Auto-Capitalization: Uses rules to detect sentence boundaries, newlines, and specific abbreviation patterns (like e.g. or i.e.) that shouldn't trigger capitalization.
    • Auto-Spacing: Uses regex patterns to determine whether spaces should be inserted between two words or punctuation marks.
    • Context Peeking: If context_sensitive_dictation is enabled, the dictation_peek action briefly selects surrounding text to check whether a space or capitalization is needed based on pre-existing text.
    • Prose Modifiers: Formats the next word according to rules such as "cap" or "no space".

Voice Commands and Grammars

  • text.talon defines the voice triggers that users speak to insert text or modify existing output. It exposes commands to:
    • Dictate free-form text: phrase <user.text>
    • Apply complex formatting rules inline.
    • Reformat previous utterances (e.g., "nope that was all caps").
    • Access and manipulation of the phrase history.

Phrase History and Corrections

  • phrase_history.py tracks the user's recently spoken phrases. This module enables powerful correction commands like "scratch that" (which deletes the last spoken phrase character-by-character) or "select that". It also features an optional interactive IMGUI popup showing the most recent phrases, allowing users to repeat or copy previous dictation by number.

Supporting Lists and Dictionaries

To make the prose capture rules functional, several .talon-list files map specific spoken forms to their written representations or underlying actions:

  • prose_modifiers.talon-list: Maps spoken commands like "cap", "no cap", and "no space" to formatter callbacks.
  • prose_snippets.talon-list: Defines spoken macros for structural layout elements like "new line", "new paragraph", "smiley", and smart quotes.
  • currency.talon-list: Contains standard currency configurations ("dollar" to $, "euro" to ) used by the currency capture group in the formatting engine.
  • phrase_ender.talon-list: Defines phrases (like "over") used to explicitly anchor the end of a dictation sequence.