Applescript or other Technique 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?

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.


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?