Alternative way for the issue "Permissions Policy Violation: Microphone Not Allowed in Outlook Add-In"

Shephin Philip 0 Reputation points
2024-05-31T13:36:43.1133333+00:00

Our team has encountered an issue with enabling the microphone while developing  outlook add in that has speech recognition as main feature. It appears that a recent update to Outlook on the web is blocking the usage of the microphone within extensions. We have tested other applications that also utilize the microphone, and they are experiencing the same problem.

The issue began on May 18th onwards, and we are seeing the following error message:

outlook-web-16.01.js:20 [Violation] Permissions policy violation: microphone is not allowed in this document.

I am using outlook solutions MessageRead.js file.Visual studio 2022.

Investigation So Far:

  1. Enabling Microphone Access: I have ensured that the microphone access is enabled in the browser settings.
  2. Checked Permissions Policies: Tested with appropriate permissions policies are set in the HTML meta tags and headers.
    <meta name="permissions-policy" content="microphone=(self)">
  3. We have also tried with integrating `devicepermission API'  which is successfully poping  up for asking user permission for microphone access. But still after clicking on  "Allow once" or " Allow Always" , still the issue persists.
  4. We have testing in our outlook desktop but the microphone is not getting ON.

Browser: checked on Microsoft Edge , Chrome and outlook desktop
Operating System : Windows 11

Our Microsoft 365 account type is Business Standard. We are using Azure speech recognition .

Can anyone please help me to understand the reason behind this microphone blockage and suggest a solution to resolve it?

if this problem is related to an Outlook update, is there an alternative workaround or method to regain microphone functionality within our Extension?

We have added a function for device permission.

`
// Ensure the microphone access request is made correctly

async function requestMicrophoneAccess() {

 try {

     const deviceCapabilities = [Office.DevicePermissionType.microphone];

     Office.devicePermission.requestPermissionsAsync(deviceCapabilities, async (asyncResult) => {

         if (asyncResult.status === Office.AsyncResultStatus.Failed) {

             console.error('Error requesting permissions:', asyncResult.error.message);

             handleErrorAndPrintMessage(asyncResult.error.message);

             return;

         }

         if (asyncResult.value) {

             console.log("Permission granted.");

             await audioContext.resume();  // Ensure context is resumed after user gesture

             recognizer.startContinuousRecognitionAsync();


           

         } else {

             console.log("Permission denied.");

             handleErrorAndPrintMessage('Permission denied by the user.');

         }

     });

 } catch (error) {

     console.error('Error accessing microphone:', error);

     handleErrorAndPrintMessage(error);

 }
``` }  
`` ` ``

![User's image](/api/attachments/d82c8639-ea3f-446f-93b4-f8ebb3ef79f6?platform=QnA)

When clicked on the "Always allow"  or "Allow once" ,  then we it shows like this   
  
![User's image](/api/attachments/debaed54-fcbe-4595-8d65-eefddd514508?platform=QnA)

Outlook
Outlook
A family of Microsoft email and calendar products.
3,216 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
911 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,642 questions
0 comments No comments
{count} votes