4

I'm trying to pass .wav file to Google Web Speech API Demonstration with

"--use-file-for-fake-audio-capture=/path/to/file.wav"

Using Web Speech API requires selecting a language and clicking the microphone icon. In result, I expect the .wav file to be recognized by Chrome's speech recognition.

My current code:

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options

path = '/home/audio/test2.wav'

chrome_options = Options()

driver = webdriver.Chrome('/home/chromedriver',
                          chrome_options=chrome_options)

driver.get('https://www.google.com/intl/pl/chrome/demos/speech.html')

select = Select(driver.find_element_by_id('select_language'))
select.select_by_visible_text('Polski')

driver.find_element_by_id('start_button').click()

chrome_options.add_argument("--use-file-for-fake-audio-capture={0}".format(path))

Everything works just fine to the moment of clicking the start button / microphone icon - I allow the browser to access the microphone but the .wav file isn't passed.

Is there any option to update the options while the webdriver is running or is there any other option to pass that audio file to the browser?

Thank you!

miszo
  • 83
  • 4

1 Answers1

-1

You need to add this option to chrome :

chrome_options = Options()
chrome_options.add_argument("--use-fake-ui-for-media-stream")

Seema Nair
  • 119
  • 7