AppleScript or Other Technique To Enable/Disable Voice Control on Catalina

I recently installed Catalina and I am very impressed with the potential for Voice Control to automate various parts of my work.

However, I am disappointed in the degree to which my 2017 Retina 5K iMac slows down when I activate Voice Control - and I am surprised I have not read more about others with similar experiences. Maybe this is because I use multiple monitors and multiple spaces? Just swiping between spaces slows down very notably when Voice Control is turned on.

I may wind up upgrading this computer - which will raise the question of whether I should get a newer iMac vs. an iMac Pro vs the new Mac Pro. For now it would be helpful to have a Macro so I can quickly turn Voice Control on/off at will.

The checkbox under System Preferences does not have an obvious way to automate it in KM. Do I need to step through the menus and then use Find Image to identify the checkbox? Or is there a way via Applescript to enable/disable voice control? Other suggestions?

1 Like

I made some progress using UI Browser.

I believe this is very close - but the line to "select static text" and thus select the Voice Control option is not working - the script cancels at that point.

Ideas?

activate application "System Preferences"
tell application "System Events"
   tell process "System Preferences"
      click button "Accessibility" of scroll area 1 of window "System Preferences"
      select static text "Voice Control" of UI element 1 of row 13 of table 1 of scroll area 1 of window "Accessibility"
      click checkbox "Enable Voice Control" of group 1 of window "Accessibility"
   end tell
end tell

Well this Macro works - but it is not elegant and has a delay in it so the keystrokes work.

Any improved ideas for this?

Thank you for sharing. I use voice control mainly for dictation and a keyboard shortcut to enable/disable Is needed
I have found that

  • you could leave open the preference pane with voice control in the background
  • simply use the Applescript as in your post to check the box as a KM macro with a hotkey assigned
  • with a hotkey to trigger the macro, dictation can be turned on and off with ease(a 2 second delay), the preference pane does not even come to the foreground

This works quite well.Thank you for sharing

1 Like

Not sure if this will help, but this will at least open System Preferences at Voice Control.

tell application "System Preferences"
	reveal anchor "Dictation" of pane id "com.apple.preference.universalaccess"
	activate
end tell

You'd still need to use the UI scripting part to toggle the checkbox though.

 

[EDIT]

I added the UI scripting part:

tell application "System Preferences"
	reveal anchor "Dictation" of pane id "com.apple.preference.universalaccess"
	-- activate
end tell

delay 0.5
tell application "System Events"
	tell process "System Preferences"
		click checkbox "Enable Voice Control" of group 1 of window "Accessibility"
	end tell
end tell

tell application "System Preferences" to quit

This works for me, but you'll probably need to tweak the delays for your machine.

[/EDIT]

4 Likes

Excellent - much appreciated

Can I ask where you found the info to write this?

I have a script that grabs the ID of the current pane open in System Preferences, copies it to the clipboard, and also shows the name of all the panes contained within it.

 

tell application "System Preferences"
	
	set currentPane to get current pane
	set paneID to id of currentPane
	
	set the clipboard to paneID as text
	display dialog quoted form of paneID & " copied to clipboard"
	
	-- Get names of every pane contained within the preference pane
	set the result to get the name of every anchor of pane id paneID
	set paneNames to the result
	
end tell

That's very helpful - big thanks

This is fantastic--thank you!

@peternlewis I would still love to have native Keyboard Maestro support for toggling voice control. This is especially the case because it turns out that if the cursor is in a text field like this one (within Chrome), the voice control "type" command does not work. So if I want to dictate, I have to turn OFF voice control, and then turn ON dictation [and of course turn back on voice control] :crazy_face:

2 Likes

This is fantastic!
Thank you

How would you make it specifically turn off or on?

EDIT: solved. I had the system check to see if Dictation is running – doesn't work, though if you also want to be dictating

if application "DictationIM" is not running then

tell application "System Preferences"
	reveal anchor "Dictation" of pane id "com.apple.preference.universalaccess"
	-- activate
end tell

delay 0.5
tell application "System Events"
	tell process "System Preferences"
		click checkbox "Enable Voice Control" of group 1 of window "Accessibility"
	end tell
end tell

tell application "System Preferences" to quit
end if
1 Like

Jono, that was PHENOMENAL! Thanks so much, Andrew

Just out of curiosity what keyboard shortcut combo are you guys using to trigger this?

Hyperkey + Home

Thanks for reminding me of Voice Control on macOS Catalina. Seems to work really great. (I have to get used to using it though…)

1 Like

Hi all,
Thanks for the work here,
I came across this topic while looking for a solution to turning on Voice Control for standard users accounts on macOS Catalina (education accessibility environment).
Frustratingly, when trying to turn on Voice Control for standard users, it prompts for admin credentials:

I'm wondering if anyone would know how to use either apple scripting or any other way of getting this to authenticate without manually entering the details for every student.

Okay, so I'm close to success with this, (but not quite there yet)

I came across some code on thread: https://apple.stackexchange.com/questions/181423/filling-the-inputs-of-securityagent-if-they-exist

I've mixed in code from the above link and am now in the process of the trial and error troubleshooting. In case anyone is interested in this I'll add my findings and hope that it helps somebody else in future.

Thanks
Dan

2 Likes

I am interested in shell commands (or Automator or Applescript or..) to 'Wake Up' and 'Go to Sleep' System Preferences/Accessibility/Voice Control once it has been enabled.
I am also intrigued by the fact that System Preferences/Accessibility/Voice Control responds to the 'Wake Up' command while asleep.. Do I need System Preferences/Accessibility/Voice Control at all?
I am running Catalina on a Mac Pro 7,1.
TIA,
Jon

I have a MacBook Air with i5, am new to Catalina and to AppleScript, but I am totally relating to the problems encountered with Voice Control to the point where I have been needing to toggle Voice Control on and off just to compose this message. I have been working with Apple engineering but the current recommendation is to reinstall the operating system.

What I have noticed by monitoring the memory section of the activity monitor, though, is that the memory for the program Dictation has gotten as high as 5 GB. Earlier than that, though, the response time for voice control begins to slow to the point where it becomes inoperable and needs to be reset. I admire the nifty ways others here have created to program a shortcut. As a layman to all of this, I have been asking Siri to toggle it for me. I would like to try using AppleScript to experiment with the program language suggested but have a couple questions -- for one, can I use the same suggestions to toggle Voice Control OFF? Also, I am not clear on some of the words in the programs, as they were cropped off.

I am grateful to have run across this thread, as now I understand this to be a design problem and not due to the malfunction of my personal computer. Thank you to all who contribute to this thread. I will keep a close eye on updates.

1 Like

Hey all,

I haven't really kept up with this thread since last posting as other work priorities took over, however I'm back to revisiting the Voice Control problem, both on Catalina and Big Sur.

@Jon_K I couldn't find any shell commands to turn on Voice Control when I last looked into this, and I did research extensively into it before I ruled it out.

I found that there was a file that could be altered (can't remember off the top of my head at the moment which one) that did result in the check box for Voice Control being checked, however it did not actually launch dictation or voice control in the initial instance until going in and manually toggling the check box (which then resulted in admin credentials box), It's as though the act of checking the box also launches a process, and I couldn't work out how to call that process by any other method.

On subsequent logins after Voice Control had been turned on at least once, it did launch the Voice Control service but in my environment this isn't workable to have to manually enable the service for every new user at these computers, from an Administrator.

@kareem33 Yeah it's frustrating that there are issues with this, particularly when third party vendors (Nuance / Dragon Naturally) dropped out of producing for macOS due to how difficult the operating system is getting to develop for due to Apples security hardening.

/start rant... I'm all for a secure operating system, but hardening the system while providing such a detrimental affect to security and product options is not a great outcome for users. As an admin of a company who is buying hundreds of macOS devices per year, the lack of MDM toolset functions to adequately manage usability settings like this is incredibly frustrating, and leading us to develop hacky work arounds which ultimately compromise the security and integrity of our overall environment. /end rant.

In answer to your question, Yes you would be able to toggle voice control off in the same way, I believe there is also a phrase you can enable to turn voice control off in the voice control settings if that is easier. It is unticked by default, so you'd need to go in to voice control commands to enable it. (Technically you could automate that too)

If you need to turn it off and on regularly you could say "Turn off Voice Control" and then follow it up with "Hey Siri, Turn on Voice Control" to avoid scripting. (assuming that voice control would be responsive to you)

Anyway, My organisation are looking at this again, I think on the few computers we'll be using Voice Control on we might bite the bullet and make the users Administrators rather than standard users, however this makes us a little uneasy at the thought.

I did also feed my comments on Voice Control for standard users back to Apple through the appleseed beta program for Big Sur... disappointingly, I never received a reply.

If I have any breakthroughs, I'll update this post.

Thanks
Dan

2 Likes