Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support microphone on 0.0.0.0 via https #3872

Closed
wants to merge 3 commits into from

Conversation

janmaltel
Copy link

@janmaltel janmaltel commented Apr 15, 2023

Description

Missing microphone support is a recurring issue (#2551, #3819, #3846).

As proposed by #2551 (comment), one solution is to use openSSL and https:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes

and add the certfile at launch method, and block method
demo.launch(server_name="0.0.0.0", ssl_certfile="/path/to/cert.pem", ssl_keyfile="/path/to/key.pem")

The thing is that it requires also to pass the ssl cert file in the requests.get() call in blocks.py, which is what this PR does.

The fix is backward compatible in the sense that the verify variable is set to True (=default value for verify in requests.get(verify=verify)) if no ssl_certfile is provided.

I tested the changes locally with
demo.launch(server_name="0.0.0.0", ssl_certfile="/path/to/cert.pem", ssl_keyfile="/path/to/key.pem")
and
demo.launch(share=False) (so with 127.0.0.1).

Closes: #2551

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 馃憢 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3872-all-demos

@abidlabs
Copy link
Member

Hi @janmaltel thanks so much for making this PR! It looks like this PR coincides with another one designed to solve the same issue: #3873

I'll go ahead and close this one as we are adding support for websockets too in the other one. But thank you nevertheless for starting this!

@abidlabs abidlabs closed this Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error when mic/webcam are not accessible in HTTP environment
3 participants