# Microphone access for a deployed Gradio app on E2

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%3E%5C
**Category:** Beginners\
**Created:** [September 24, 2024, 8:57am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335 "2024-09-24T08:57:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkurdomanenko](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dkurdomanenko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdkurdomanenko)%5C
**Post date:** [September 24, 2024, 8:57am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%2F1 "2024-09-24T08:57:53Z")

</div>

I need to create a demo to test an STT Agent. I created a simple Gradio app and deployed it on EC2 instance. However, when I launch it, my browsers(Safari and Chrome) report no microphone provided. Is it possible to deploy the app in a way that allows microphone access?

I’ve included a basic example of my Gradio app, which also doesn’t work.

```auto
import gradio as gr

audio = gr.Microphone(sources=["microphone"], type="filepath")
ui = gr.Interface(
    fn=lambda x: x,
    inputs=audio,
    outputs=audio,
    allow_flagging="never"
)

if __name__ == ' __main__':
    ui.launch(server_name="0.0.0.0")

```

I tried to change port, but the results are the same. I also tried to use NGINX, but I couldn’t write a proper script.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 9:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%2F2 "2024-09-24T09:12:40Z")

</div>

This issue sounds tricky.

> <https://github.com/gradio-app/gradio/issues/3819>
>
> \### Describe the bug
> 
> I setup the gradio app with public address. When I use saf…ari to open the url, it doesn't prompt me for microphone access. However, when I setup the gradio app with local address, it works properly. What's the problem? Thank you in advance.
> 
> \### Is there an existing issue for this?
> 
> \- \[X\] I have searched the existing issues
> 
> \### Reproduction
> 
> I setup the gradio app with public address. 
> I use safari to open the url, it doesn't prompt me for microphone access. 
> 
> \### Screenshot
> 
> \_No response\_
> 
> \### Logs
> 
> \`\`\`shell
> None
> \`\`\`
> 
> 
> \### System Info
> 
> \`\`\`shell
> Ubuntu 20.04
> gradio 3.25.0
> \`\`\`
> 
> 
> \### Severity
> 
> annoying

> When I set “server.launch(share=True)”, I use this url ([https://1a9b77cb89ac33f546.gradio.live](https://1a9b77cb89ac33f546.gradio.live)), and it is ok.  
> However, when I set “server.launch(server\_name=“0.0.0.0”)”, I use my own public url (for example, [http://101.40.163.105:7860](http://101.40.163.105:7860)), it doesn’t prompt me for microphone access.

> this is not a Gradio issue but it’s actually due to the fact that modern browsers block microphone access in http environments. We have an existing issue to provide clearer error messages when this happens: [#2551](https://github.com/gradio-app/gradio/issues/2551)

---

<div class="post-metadata">

**Author:** ![dkurdomanenko](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dkurdomanenko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdkurdomanenko)%5C
**Post date:** [September 24, 2024, 10:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%2F3 "2024-09-24T10:16:21Z")

</div>

Yes, it works for STT, but if I decide to play audio, the app will crash. Are there any solutions?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 11:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%2F4 "2024-09-24T11:35:52Z")

</div>

There are a few ways to do it, but I’m kind of a fossil, so I’m not familiar with internet-related implementations…

> <https://github.com/gradio-app/gradio/issues/4318>
>
> \### Describe the bug
> 
> gr.Audio() seems to be not working on the Andriod Firefo…x browser, it can't ask for audio permissions.
> but, it's working fine on my PC browser (chrome and Firefox).
> 
> Note: My Firefox has the Android microphone permission enabled and the browser set audio to "Ask to Enable"
> 
> It could be caused by the incompatibility of the javascript browser API for asking for audio permission.
> Please fix this bug.
> 
> Thanks.
> 
> \### Is there an existing issue for this?
> 
> \- \[X\] I have searched the existing issues
> 
> \### Reproduction
> 
> Here is just the audio field:
> \`\`\`python
> audio = gr.Audio(source="microphone", show\_label=False, type="filepath", format="mp3").style(container=False) 
> \`\`\`
> 
> \### Screenshot
> 
> \_No response\_
> 
> \### Logs
> 
> \`\`\`shell
> No logs
> \`\`\`
> 
> 
> \### System Info
> 
> \`\`\`shell
> my device info:
> Android version: 12
> Browser: Firefox
> Note: My Firefox has the Android microphone permission enabled and the browser set audio to "Ask to Enable"
> \`\`\`
> 
> 
> \### Severity
> 
> serious, but I can work around it

> <https://github.com/gradio-app/gradio/issues/2551>
>
> \### Describe the bug
> 
> \## Issue.
> I deployed an example of microphone testing o…n my local machine.
> Knocking on http://127.0.0.1:7860/ (or http://localhost:7860/), everything works.
> Knocking on http://MY\_IPV4:7860/, the stop recording button does not work.
> On a local machine, it doesn't matter to me which URL to use. But if you deploy it on a server (for example, in a Docker container), and access the IP of the server, then this is critical.
> P.S., only the stop recording button does not work, the rest functions correctly.
> 
> \## Details.
> When you click the Record from microphone button in the browser console the following:
> !\[Record from microphone\](https://user-images.githubusercontent.com/66529793/198241461-aebb5322-46e5-4b14-a230-907f8295b376.png)
> \_Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getUserMedia')
> at le (Audio.svelte:103:51)
> at HTMLButtonElement.x (Audio.svelte:181:4)
> le @ Audio.svelte:103
> x @ Audio.svelte:181\_
> 
> When you click the Stop recording button in the browser console, the following (this button does not work as intended):
> !\[Stop recording\](https://user-images.githubusercontent.com/66529793/198241487-8d6505ff-f8bc-4bc1-9bcf-4418874c9d49.png)
> \_Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'stop')
> at HTMLButtonElement.v (Audio.svelte:198:3)
> v @ Audio.svelte:198\_
> 
> 
> \### Is there an existing issue for this?
> 
> \- \[X\] I have searched the existing issues
> 
> \### Reproduction
> 
> You can reproduce the error by running \`main.py\` with the code below.
> 
> \### main.py
> \`\`\`python3
> import gradio as gr
> 
> 
> def test\_micro(path2audio):
> return path2audio
> 
> 
> if \_\_name\_\_ == '\_\_main\_\_':
> demo = gr.Interface(fn=test\_micro,
> inputs=gr.components.Audio(source="microphone", type="filepath", label="Speaker"),
> outputs="text")
> demo.launch(server\_port=7860, server\_name="0.0.0.0", debug=True, share=False)
> 
> \`\`\`
> 
> \### Screenshot
> 
> \_No response\_
> 
> \### Logs
> 
> \`\`\`shell
> The Python console has standard output, there are no errors.
> 
> 
> Running on local URL: http://0.0.0.0:7860
> 
> To create a public link, set \`share=True\` in \`launch()\`.
> \`\`\`
> 
> 
> \### System Info
> 
> \`\`\`shell
> Python version: 3.9.10.
> Gradio version: 3.7.
> Browser: Mozilla FireFox (102.3.0esr, 64-bit); Google Chrome (version 106.0.5249.119, 64-bit).
> OS: Linux; Windows (problem everywhere).
> \`\`\`
> 
> 
> \### Severity
> 
> blocking all usage of gradio

---

<div class="post-metadata">

**Author:** ![StefanNa3Shape](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/stefanna3shape/32/34590_2.png) [@StefanNa3Shape](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FStefanNa3Shape)%5C
**Post date:** [January 22, 2025, 5:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmicrophone-access-for-a-deployed-gradio-app-on-e2%2F108335%2F5 "2025-01-22T17:59:46Z")

</div>

How did you solve it in the end?  
I am kind of having the same issue now
