2

I use the speech dictation tool to dictate text. But I do so in two different languages. To change the language of the dictation tool requires mouse clicking a few times which I try to avoid (hence the use of dictation tool). Is there a way to create a keyboard shortcut that cycles between the two dictation languages?

Previous knowledge on this topic

A previous answer was given in 2012 using Apple script and bash scripts, see How to use applescript to toggle the language setting of new dictation tool (10.8). Unfortunately this no longer works due to changes in macOS. Daniel suggests an alternate script in the same thread that worked in 2020, but as they correctly predict, it also no longer works in 2023.

I'm not able to adapt either of Daniel or Lri's scripts to work with Ventura. For reference, this is Lri's suggestion

delay 0.3 -- time to release modifier keys if the script is run with a shortcut
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"

And this was Daniel's updated version

tell application "System Preferences"
    reveal anchor "Dictation" of pane "com.apple.preference.speech"
end tell
delay 1
tell application "System Events" to tell application 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 "Hungarian (Hungary)" of menu 1
        else
            click menu item "English (United States)" of menu 1
        end if

    end tell
end tell
quit application "System Preferences"

I have via some help surmised that the "updated name" of com.apple.preference.speech is x-apple.systempreferences:com.apple.Keyboard-Settings.extension. But substituting this in either code above fails to yield positive results, instead giving me the following error

error "System Settings got an error: Can’t get pane "x-apple.systempreferences:com.apple.Keyboard-Settings.extension"."

A similar question was asked recently, but got no answers.

To sum up

I'm looking for a way to easily and quickly change between two languages in the dictation tool. The solution should preferably create a shortcut, and use either an apple script or a bash script. Though I am open to other solutions if they are viable.


Edit, 2024-03-05

This question has been marked as a duplicate of a previous answer. This is wrong. The previous answer might have worked for old versions of macOS. My question is specific to Ventura (or now, Sonoma), as per the title. The inner workings of macOS has changed enough in the intervening years that that answer no longer works.

lxgr's suggestion of working with changing input methods seems to be the best solution so far. But I would prefer to not have to change my keyboard layouts when I'm dictating. So I hope we can keep the question open in case anyone else finds a solution.

0

1 Answer 1

1

I've recently noticed that the "change input method" keyboard shortcut (^ Control Space by default) also works for changing the dictation language, although it seems to be quite buggy unless there's also a corresponding keyboard layout set up.

For example, setting up "U.S." and "German" as keyboard layouts and "English (United States)" and "German (Germany)" lets me switch between English and German dictation by pressing ^ Control Space.

It has the disadvantage of also switching keyboard entry methods simultaneously, but maybe that works for you?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .