microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.59k stars 1.54k forks source link

Microphone requesting access on each click #5005

Closed Deepanshu2017 closed 9 months ago

Deepanshu2017 commented 9 months ago

Is it an issue related to Adaptive Cards?

No

Is this an accessibility issue?

No

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

Bundle (webchat.js)

Which hosting environment does this issue primarily affect?

Web apps

Which browsers and platforms do the issue happened?

Browser: Edge (latest), Browser: Chrome (latest)

Which area does this issue affect?

Speech

What is the public URL for the website?

No response

Please describe the bug

I've been working with createBrowserWebSpeechPonyfillFactory and also tested createCognitiveServicesSpeechServicesPonyfillFactory. My project involves integrating an Azure chatbot with WebChat using Direct Line speech. While the speech recognition and response functionalities are operating correctly, I'm encountering an issue with microphone permissions. Each time the microphone button is clicked, the browser (tested on Edge, Chrome, and Brave) prompts for microphone access. Ideally, this permission should be requested just once and not repeatedly with every message.

image

Here is my entire code

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>Web Chat: Browser-supported speech</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    <style>
      html,
      body {
        height: 100%;
      }

      body {
        margin: 0;
      }

      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="webchat" role="main"></div>
    <script>
      (async function() {
        const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
        const { token } = await res.json();
        window.WebChat.renderWebChat(
          {
            directLine: window.WebChat.createDirectLine({ token:'MYVALUE' }),
            webSpeechPonyfillFactory: window.WebChat.createBrowserWebSpeechPonyfillFactory()
          },
          document.getElementById('webchat')
        );

        document.querySelector('#webchat > *').focus();
      })().catch(err => console.error(err));
    </script>
  </body>
</html>

Do you see any errors in console log?

No response

How to reproduce the issue?

I am using a sample from Direct line speech

What do you expect?

It should ask for microphone permission at the start once and not on each message.

What actually happened?

It is asking for microphone permission on each message.

Do you have any screenshots or recordings to repro the issue?

No response

Adaptive Card JSON

No response

Additional context

No response

Deepanshu2017 commented 9 months ago

Apparently deploying the same HTML by server works! Closing the issue.