Open Tyriar opened 7 months ago
Related: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2238
As it turns out we would have to implement this on our own, the library does not provide this information, nor plans to add this in the future.
I was really hoping that we can detect this using web APIs and I have tried the following (needs [1] for permissions):
navigator.permissions.query(
{ name: 'microphone' } as any
).then(function(permissionStatus){
console.log(permissionStatus.state); // granted, denied, prompt
})
But this always returns denied
. I was then hoping this would do it:
navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
/* permissions */
}).catch((error) => { /* no permissions */ });
But I always seem to be getting a stream even when permissions are not granted.
If someone has more ideas, opening for help wanted.
@bpasero I'm guessing you would need some mac native code to check the OS-level permissions for the app, the query
API giving denied all the time seems correct here as the app is unable to use the mic completely.
@Tyriar I think the navigator.permissions
API should return granted
when I did grant permissions, but I also see that not all permissions can be queried like that, so its possible that microphone
is not one of them.
I would like to avoid having to write native code for this and ideally find a web solution that works on all platforms. I am sure other apps must have this issue too?
Deepak or Matt would know more about using permissions
, my experience with it is fairly limited to mainly just clipboard access.
At least https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query indicates a lot more than just clipboard.
Testing https://github.com/microsoft/vscode-copilot/issues/4203
Repro:
Clicking the mic continues to toggle the state but doesn't actually do any recording. Ideally we would see access is restricted and direct the user to the macOS mic permissions.