我正在尝试在google.com上播放音频文件。我有以下代码:
ChromeOptions options = new ChromeOptions();
options.AddArguments(
//"--allow-file-access-from-files",
"--use-fake-ui-for-media-stream",
//"--allow-file-access",
"--use-file-for-fake-audio-capture=" + AppDomain.CurrentDomain.BaseDirectory + "/audio.wav",
"--use-fake-device-for-media-stream"
);
IWebDriver chrome = new ChromeDriver(options);
此代码打开一个使用C#中的selenium的chrome窗口,一切都按预期工作。当我去在线录音机或https://appr.tc/?debug=loopback时,我的音频文件就像它应该做的那样播放。但是,当我去google.com时,我点击搜索栏末尾的语音按钮搜索没有任何反应。 (当我刚刚说话的时候google.com会认出我的声音)我错过了什么,为什么它不起作用?我试图在C#http://www.testautomationguru.com/selenium-webdriver-google-voice-search-automation-using-arquillian-graphene/中重新创建它。我可以在页面上执行某些javascript代码以使其正常工作吗?如果可以解决问题,我不介意使用firefoxdriver而不是chrome。
由于
编辑:我在https://webrtc.org/testing/上找到了更多信息,所以我想这意味着google.com没有使用webrtc getUserMedia()调用来获取音频?我可以修改页面的任何方式,或者我可以更改其他设置吗?我还检查了https://speechnotes.co/,在那个网站上我的音频也没有被检测到,但是真正的麦克风是。
答案 0 :(得分:1)
google.com在javascript中使用webKitSpeechRecognition(),这是内置的chrome语音识别,请检查chrome speech recognition WebKitSpeechRecognition() not accepting input of fake audio device --use-file-for-fake-audio-capture or audio file