Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

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.

share|improve this answer
    
There seems to be an error with the syntax. ",“ or "]“ expected. –  gentmatt Aug 3 '12 at 20:59
1  
-eq doesn't work for string IIRC. –  Daniel Beck Aug 3 '12 at 21:03
    
@DanielBeck You're right. I edited the scripts and also removed the activate from the AppleScript. –  ؘؘؘؘ Aug 3 '12 at 21:29

Not sure if this helps but someone developped a "Dictation Switcher" a little utility that sits in your Mac's menu bar and makes using Dictation even easier. it can be found here: http://fouquet.me/apps/dictationswitcher/

Understand you had the pleasure to write your own script but just in case, I thought this might help... :-)

share|improve this answer
    
Awesome! Thank you very much. –  gentmatt Mar 3 '13 at 8:13

check this http://fouquet.me/apps/dictationswitcher/ is very nice. I Hope this help

share|improve this answer

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!

share|improve this answer
    
To be honest, this solution is not very beautiful (I don't like seeing the preferences being opened and all that...), but it works so I'll go with this for know. Thanks for sharing this! I'm already using FastScripts, so this is fine. –  gentmatt Aug 3 '12 at 20:36
2  
You can leave out the activate, it will work just as well and not show the window. –  Daniel Beck Aug 3 '12 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.