gradio部署whisper在web端,点击录音以后报错,报错截图:
Error Media devices could not be accessed. Check that you are running on a secure origin (https) or localhost (or you have passed a valid SSL certificate to ssl_verify), and you have allowed browser access to your device.
网上搜到的,大概意思就是这个错误通常是因为浏览器安全策略阻止了对媒体设备的访问。现代浏览器要求网站在尝试访问用户的摄像头或麦克风时使用HTTPS协议,以确保连接是安全的。如果应用没有使用HTTPS,或者没有在本地主机(localhost)上运行它,浏览器就会阻止访问媒体设备。
说人话就是,我这个是http://服务器ip:端口port,得换成https://服务器ip:端口port
解决办法:
执行下面的,根据提示输入信息等,自己创建ssl:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes
大概是这样:
完成以后就得到了cert.pem 和key.pem两个文件,
然后在gradio代码中修改launch: app.launch(share=True, server_name="0.0.0.0", ssl_certfile="./cert.pem", ssl_keyfile="./key.pem", ssl_verify=False)
这样就可以在web端,用https://服务器ip:端口port,并且正常录音了