Apple dictation doesn't learn -- make it learn

Mastering Your Mac’s Dictation: Building a Self-Improving Workflow

We’ve all been there: dictating a brilliant paragraph, only to see “sea” instead of “see,” “cell” instead of “so,” or a crucial phrase that gets consistently garbled. While Apple’s built-in dictation (powered by Siri’s intelligence) is excellent, it’s not perfect for every voice or every niche vocabulary.

This article outlines how to build a highly personalized, self-improving dictation workflow on macOS. We’ll leverage AppleScript and the Shortcuts app to create two powerful keyboard shortcuts that:

  1. Automatically correct common dictation errors and expand text snippets in your active paragraph, all from a customizable external file.

  2. Allow you to add new correction rules or snippets on the fly, directly from your document, without ever touching code.

The result is a workflow that significantly boosts productivity, handles your specific dictation quirks, and evolves with your needs.


The Core Idea: Contextual Control

The secret sauce lies in transforming a basic find-and-replace mechanism into a “smart” system. We’ll:

  • Dictate “triggers”: Instead of just speaking “to,” we might say “too one” or “two two” to disambiguate homophones.

  • Post-process: A custom macro will take the raw dictated text and apply a list of pre-defined corrections and expansions.

  • Self-learn: A second macro will allow you to quickly add new rules to your correction list, making the system smarter each time you encounter a recurring error.

Part 1: The “Correction & Snippet” Macro (⌘M)

This is your primary tool. When triggered, it will read your master list of rules from a simple text file and apply them to the last paragraph of your currently active document (works with Microsoft Word and Apple Pages).

Step 1: Create Your MyReplacements.txt File

This plain text file is the “brain” of your system. It contains all your correction rules and text snippets, separated by a comma.

  1. Open TextEdit (or any plain text editor).

  2. Go to Format > Make Plain Text.

  3. Enter your rules, one per line, with the “find” text first, then a comma, then the “replace” text. For multi-line snippets, use \n to represent a new line.

Crucial Order: Place your most specific (longer, multi-word) rules before your general (shorter, single-word) rules. This prevents a simple rule from breaking a more complex one.

Example: MyReplacements.txt

# --- Snippet Triggers (Examples) ---
rejection email,Dear applicant,\n\nThank you for your interest in the position. While your qualifications are impressive, we have decided to move forward with other candidates whose experience more closely matches our current needs.\n\nWe wish you the best in your job search.\n\nSincerely,
sig,John Doe\nSenior Analyst
addr,123 Main Street\nAnytown, USA 12345
tysm,Thank you so much for your help with this!

# --- Homophone Override Triggers (Specific, Multi-Word) ---
# Dictate "too one", "two one", or "to one" to force "to"
too one,to
two one,to
to one,to
# Dictate "two more" to force "too" (as in "too many")
two more,too
# Dictate "two two" to force "two" (as in "number two")
two two,two

# --- General Dictation Corrections (Short, Single-Word) ---
cell,so
right,write

  1. Save this file in your Documents folder as MyReplacements.txt.

Step 2: Create the AppleScript

This script reads your MyReplacements.txt file and applies the rules. It also handles the \n characters for multi-line snippets.

AppleScript

# --- CONFIGURATION ---
set replacementsFile to (path to documents folder as text) & "MyReplacements.txt"

# --- SCRIPT LOGIC (No need to edit below this line after initial setup) ---
try
	set fileContent to paragraphs of (read file replacementsFile)
on error
	display dialog "Error: The replacements file was not found at " & replacementsFile
	return
end try

tell application "System Events" to set activeApp to name of first application process whose frontmost is true

if activeApp is "Microsoft Word" then
	tell application "Microsoft Word"
		try
			set targetParagraph to the last paragraph of the active document
			set myText to the content of targetParagraph
			
			repeat with aLine in fileContent
				if aLine is not "" then
					set findText to my getField(aLine, ",", 1)
					set replaceText to my getField(aLine, ",", 2)
					set myText to my replaceText(findText, replaceText, myText)
				end if
			end repeat
			
			# Handle the newline characters for snippets
			set myText to my replaceText("\\n", return, myText)
			
			set the content of targetParagraph to myText
		on error
			display dialog "Could not process the last paragraph in Word."
		end try
	end tell
	
else if activeApp is "Pages" then
	tell application "Pages"
		try
			tell the front document
				set targetParagraph to the last paragraph
				set myText to the value of targetParagraph
				
				repeat with aLine in fileContent
					if aLine is not "" then
						set findText to my getField(aLine, ",", 1)
						set replaceText to my getField(aLine, ",", 2)
						set myText to my replaceText(findText, replaceText, myText)
					end if
				end repeat
				
				# Handle the newline characters for snippets
				set myText to my replaceText("\\n", return, myText)
				
				set the value of targetParagraph to myText
			end tell
		on error
			display dialog "Could not process the last paragraph in Pages."
		end try
	end tell
	
else
	display dialog "This script only works when Microsoft Word or Pages is the active application."
end if

# --- Helper Functions (These perform the actual text manipulation) ---
on getField(theText, theDelimiter, theField)
	set oldDelimitators to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	set theFields to text items of theText
	set AppleScript's text item delimiters to oldDelimitators
	return item theField of theFields
end getField

on replaceText(find, replace, subject)
	set oldDelimitators to AppleScript's text item delimiters
	set AppleScript's text item delimiters to find
	set textItems to text items of subject
	set AppleScript's text item delimiters to replace
	set subject to textItems as text
	set AppleScript's text item delimiters to oldDelimitators
	return subject
end replaceText

Step 3: Create the Shortcut and Assign ⌘M

  1. Open the Shortcuts app on your Mac.

  2. Click + to create a new shortcut.

  3. Click the “Shortcut Details” icon (sliders/info ‘i’ icon) on the right.

  4. Check “Use as Quick Action” and set “Receives” to No Input.

  5. Search for “Run AppleScript,” drag it into your shortcut, and paste the entire script from Step 2 into the action box.

  6. Rename the shortcut (e.g., “Fix & Expand Paragraph”).

  7. Go to System Settings > Keyboard > Keyboard Shortcuts… > Services.

  8. Find your new Quick Action, click “Add Shortcut,” and press ⌘M (or another desired shortcut).


Part 2: The “Add Rule to List” Macro (⌃⌘A)

This macro streamlines the process of updating your MyReplacements.txt file. You can add new rules or snippets without leaving your document.

Step 1: The AppleScript for Adding Rules

This script copies selected text, appends it to your MyReplacements.txt file, and then deletes it from your document.

AppleScript

# --- CONFIGURATION ---
set replacementsFile to (path to documents folder as text) & "MyReplacements.txt"

# --- SCRIPT LOGIC ---
tell application "System Events"
	keystroke "c" using {command down}
	delay 0.1 # Pause for clipboard to set
end tell
set theRule to the clipboard

try
	set fileHandle to open for access file replacementsFile with write permission
	write return & theRule to fileHandle starting at eof
	close access fileHandle
on error
	try
		close access file replacementsFile
	end try
	display dialog "Error: Could not write to the replacements file at " & replacementsFile
	return
end try

tell application "System Events"
	keystroke delete
end tell

Step 2: Create the Shortcut and Assign ⌃⌘A

  1. Open the Shortcuts app and create another new shortcut.

  2. In the details panel, check “Use as Quick Action” and set “Receives” to Text (from “Any Application”).

  3. Search for “Run AppleScript,” drag it in, and paste the script from Step 1 into the action box.

  4. Rename it (e.g., “Add to Replacements List”).

  5. Go to System Settings > Keyboard > Keyboard Shortcuts… > Services.

  6. Find your “Add to Replacements List” action, click “Add Shortcut,” and press ⌃⌘A (or another desired shortcut).


Your Dynamic Workflow in Action

  1. Dictate: Use macOS dictation to speak your text.

  2. Identify New Rule: Notice a recurring error (e.g., Siri always writes “hear” when you mean “here”).

  3. Create Rule in Document: At the end of your document (or anywhere convenient), type out the rule: here,hear.

  4. Add to List: Select here,hear with your mouse. Press ⌃⌘A. The text disappears from your document, and the rule is now saved in MyReplacements.txt.

  5. Fix Paragraph: Move your cursor to the desired paragraph (or just leave it where it is if you just dictated). Press ⌘M. Your newly added rule (and all others) will instantly apply, correcting “here” to “hear” and expanding any snippets.

Congratulations! You’ve built a truly powerful, self-improving dictation and text expansion system that adapts to your unique voice and writing needs, all without costly third-party software.