3

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.enter image description here

2

1 Answer 1

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>')
2
  • 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? Commented Jan 31, 2020 at 18:59
  • @SubhadipMondal Before you create chrome driver ! driver = webdriver.Chrome(chrome_options=options)
    – PDHide
    Commented Jan 31, 2020 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.