Change mac dictation languge quickly [duplicate]
With English not being my first language, I usually need support for at least two languages when using features like auto-correct and dictation.
Is it possible to toggle the language which is used for dictation via a shortcut?
As of now, I always have to manually navigate through the menus in the System Preferences which if far from convenient. I've tried to see if there are any pre-defined actions in Automator, but found none.
Solution 1:
You could either edit property lists that store the setting and reopen the DictationIM process:
#!/bin/bash
k="com.apple.speech.recognition.AppleSpeechRecognition.prefs DictationIMLocaleIdentifier"
if [[ "$(defaults read $k)" == en-US ]]; then
defaults write $k fr-FR
defaults write com.apple.assistant "Session Language" fr-FR
else
defaults write $k en-US
defaults write com.apple.assistant "Session Language" en-US
fi
killall -HUP DictationIM
Or use UI scripting:
tell application "System Preferences"
reveal anchor "Dictation" of pane "com.apple.preference.speech"
end tell
tell application "System Events" to tell process "System Preferences"
tell pop up button 1 of tab group 1 of window 1
click
if value is "English (United States)" then
click menu item "French" of menu 1
else
click menu item "English (United States)" of menu 1
end if
end tell
end tell
quit application "System Preferences"
Both scripts are copied from my answer to How to use applescript to toggle the language setting of new dictation tool (10.8) - Stack Overflow.
Solution 2:
Well, when I want to change languages, I just click on the name of the current language in the little dictation widget and get a menu:
Clarification: the menu will only show you the languages you have enabled in the Dictation preference pane. So by default it only shows the main language of the O.S. installation.
Solution 3:
check this http://fouquet.me/apps/dictationswitcher/ is very nice. I Hope this help
Solution 4:
I found a thread in which the following Applescript was contained:
tell application "System Events" to set p to (path to frontmost application) as string
tell application "System Preferences"
activate
reveal anchor "Dictation" of pane "com.apple.preference.speech"
end tell
tell application "System Events"
tell process "System Preferences"
tell pop up button 1 of tab group 1 of window "Dictation & Speech"
click
if (get value of attribute "AXValue") contains "English (United States)" then
click menu item "German" of menu 1
say "Dictation set to German"
else if (get value of attribute "AXValue") contains "German" then
click menu item "English (United States)" of menu 1
say "Dictation set to English"
end if
end tell
end tell
end tell
quit application "System Preferences"
activate application p
I tested it out and it works. All you have to do is change "German" to the language of your choice.
Additionally, may I suggest an application called FastScripts, which allows you to run the applescript either from the top menu bar or from a keyboard shortcut.
Hope this solved your problem!
Solution 5:
On OSX El Capitan I had difficulty getting the script by user495470 to work and likewise with the code from pasawaya. I ended up modifying the code from pasawaya to include:
repeat until exists tab group 1 of window "Dictation & Speech"
end repeat
Here's the full slightly modified script which works perfectly for me:
tell application "System Events" to set currentWindow to (path to frontmost application) as string
tell application "System Preferences"
reveal anchor "Dictation" of pane "com.apple.preference.speech"
end tell
tell application "System Events"
tell process "System Preferences"
repeat until exists tab group 1 of window "Dictation & Speech"
end repeat
tell pop up button 1 of tab group 1 of window "Dictation & Speech"
click
if (get value of attribute "AXValue") contains "English" then
click menu item "Danish (Denmark)" of menu 1
say "Dictation Danish"
else if (get value of attribute "AXValue") contains "Danish" then
click menu item "English (United Kingdom)" of menu 1
say "Dictation English"
end if
end tell
end tell
end tell
quit application "System Preferences"
activate application currentWindow