I am facing an issue that the agent voice is not w...
# ask-ai
s
I am facing an issue that the agent voice is not working on the browser in the following case, if i connectsfor the first time and browser prompts for the mic permissions it works, but if i disconnect and try again and the browser did not prompt for the permission it does not work. There is not any issues and i can hear the recording were both my voice and the agent is there.
t
Thanks for reaching out, Youssef. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It sounds like you're having trouble with the agent voice not working after reconnecting, and you're not seeing a microphone permission prompt. This usually happens because of how browsers manage microphone permissions. No worries though, here are some friendly steps to help you sort this out: 1. Check for Microphone Permissions: Before you reconnect, it's a good idea to check if the microphone permissions are already granted. You can use this little code snippet:
Copy code
const hasPermission = await navigator.mediaDevices.getUserMedia({ audio: true }).catch(() => false);
if (!hasPermission) {
  alert("Please enable microphone permissions in your browser settings and reload the page");
  return;
}
2. Handle Disconnection State: Make sure to properly clean up and reinitialize your media devices when disconnected. Here's an example:
Copy code
function onDeviceFailure(error) {
  console.error(error);
  alert("Error acquiring microphone permissions. Please grant permissions and reload.");
}
3. Provide Manual Permission Request: It’s helpful to add a button or some way for users to manually request permissions if they were denied before:
Copy code
<button onclick="requestMicrophonePermission()">Enable Microphone</button>
<script>
  function requestMicrophonePermission() {
    navigator.mediaDevices.getUserMedia({ audio: true })
      .then(stream => {
        stream.getTracks().forEach(t => t.stop());
      })
      .catch(error => console.error('Microphone permission error:', error));
  }
</script>
Following these steps should help make sure microphone permissions are handled smoothly, and guide users to enable them when needed. If you hit any snags or want a hand with anything else, just let me know—I’m here to help! Sources: complex-agents/shopify-voice-shopper/shopify-voice-frontend/extension/permi... | quickstart/src/userfriendlyerror.js