SpeechRecognition permissions in Chrome Extension

27 Views Asked by At

I'm creating a Chrome extension that uses the SpeechRecognition API.

The API is not available in general to background pages/service-workers.

I tried accessing it in the popup but ran into permissions issues. Permissions also cannot be granted via the popup or via the manifest.

I was able to get it running both in an extension window and as a content script/injection.

But for separation of responsibilities, clean code, and to access the API from a single source of truth, I tried to separate the script accessing the API into an offscreen page, which is only run after the user gives permissions via the extension window/page.

The browser registers that my extension is given microphone permissions in settings, but for some reason, I'm still getting Speech recognition error: not-allowed.

This is confusing to me, as I'm reading that once permission is granted to the extension via a user interaction in a window/page, the API should be accessible across the extension. Or am I wrong and the API is simply never accessible via a popup or off offscreen page, even after the extension is granted microphone permissions?

PS: navigator.mediaDevices.getUserMedia({audio:true}) works on the offscreen page, but not webkitSpeechRecognition

0

There are 0 best solutions below