I am developing an application where I need microphone access. So, anyone can tell me the python code for asking microphone permission in Chrome or any other Browser.
Asked
Active
Viewed 1,741 times
3
Subhadip Mondal
- 31
- 2
-
1addArguments('use-fake-device-for-media-stream') – PDHide Jan 31 '20 at 17:01
-
May be same as- https://sqa.stackexchange.com/questions/40706/how-to-allow-notification-permission-for-desktop-notifications-in-chrome-browser – Meet Feb 06 '20 at 13:11
1 Answers
2
Try the below code
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
options.add_argument('use-fake-device-for-media-stream')
driver = webdriver.Chrome(chrome_options=options)
Or else you can pass the chrome profile that has microphone enabled for your application
options.add_argument("user-data-dir=<profilepath>")
eg
options.add_argument("user-data-dir=c:\profile\user-data")
if the profile is not in user-data\default then you have to also add
options.add_argument('--profile-directory=<folder_name>')
PDHide
- 11,065
- 2
- 14
- 42
-
I have a link and when I clicked on the link it will call a python function. And also on clicking the link, I want to get microphone access. So that I can get the speech audio and then I will convert to text (using speech recognizer) and do the further process. So, where I will place the code to do all this work? – Subhadip Mondal Jan 31 '20 at 18:59
-
@SubhadipMondal Before you create chrome driver ! driver = webdriver.Chrome(chrome_options=options) – PDHide Jan 31 '20 at 19:03