pythonmacosdictation

Use OSX speech recognition without the microphone widget


Is there a way to use voice commands on OSX without the on-screen microphone widget, either on an app-specific basis or system wide?

I'm currently trying to build a speech recognition app in Python on OSX that I can use whilst playing Elite to control in-game functions and my music player. I've found this fantastic example that I'll build off, and I found a method for preventing it from interfering with game audio.

The problem I've hit is that the on-screen widget when using speech recognition interferes with playing a full-screen game. I understand the privacy/security reasons for the widget, but is there any way of "opting out" of this?

Answer needn't use Python, but bonus internet points if it does!


Solution

  • tl;dr the answer is “probably yes, try making your app full-screen”.

    Docs on recognizing speech[1] imply on-screen microphone is non-optional:

    When speech recognition is activated, an on-screen microphone and (optionally) the Speech Commands window appear.

    However, NSSpeechRecognizer docs explicitly mention[2] that full-screen apps are compatible with on-screen mike (emphasis mine):

    Setting [blocksOtherRecognizers] to YES effectively takes over the computer at the expense of other applications using speech recognition, so you should use it only in circumstances that warrant it, such as when listening for a response important to overall system operation or when an application is running in full-screen mode (such as games and presentation software).

    This, I believe, implies that if your app (the one that uses speech recognition) is full-screen, then microphone widget isn’t going to show up. Whether you can have more than one full-screen app running simultaneously is the question—you could try researching relevant APIs[3].

    Otherwise you could look into third-party speech recognition libraries for Python (last time I checked there weren’t many good options there), or try hooking up a second display and see if you can have your app with the microphone widget and the game running on different screens.

    Mac Developer Library links