Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在QWebEngineView中允许语音识别api_Python_Html_Python 3.x_Pyqt5_Qtwebengine - Fatal编程技术网

Python 如何在QWebEngineView中允许语音识别api

Python 如何在QWebEngineView中允许语音识别api,python,html,python-3.x,pyqt5,qtwebengine,Python,Html,Python 3.x,Pyqt5,Qtwebengine,我有一个小代码 <!doctype html> <head> <title>JavaScript Speech to Text</title> </head> <body> <h2>JavaScript Speech to Text</h2> <p>Click on the below button and speak something...</p>

我有一个小代码

<!doctype html>
<head>
    <title>JavaScript Speech to Text</title>
</head>
<body>
    <h2>JavaScript Speech to Text</h2>
    <p>Click on the below button and speak something...</p>
    <p><button type="button" onclick="runSpeechRecognition()">Speech to Text</button> &nbsp; <span id="action"></span></p>
    <div id="output" class="hide"></div>
    <script>
        /* JS comes here */
        function runSpeechRecognition() {
            // get output div reference
            var output = document.getElementById("output");
            // get action element reference
            var action = document.getElementById("action");
            // new speech recognition object
            var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
            var recognition = new SpeechRecognition();
        
            // This runs when the speech recognition service starts
            recognition.onstart = function() {
                action.innerHTML = "<small>listening, please speak...</small>";
            };
            
            recognition.onspeechend = function() {
                action.innerHTML = "<small>stopped listening, hope you are done...</small>";
                recognition.stop();
            }
          
            // This runs when the speech recognition service returns result
            recognition.onresult = function(event) {
                var transcript = event.results[0][0].transcript;
                var confidence = event.results[0][0].confidence;
                output.innerHTML = "<b>Text:</b> " + transcript + "<br/> <b>Confidence:</b> " + confidence*100+"%";
                output.classList.remove("hide");
            };
          
             // start recognition
             recognition.start();
        }
    </script>
</body>

JavaScript语音到文本
JavaScript语音到文本
点击下面的按钮,说点什么

从语音到文本

/*JS来了*/ 函数runSpeechRecognition(){ //获取输出div引用 var output=document.getElementById(“输出”); //获取动作元素引用 var action=document.getElementById(“action”); //新的语音识别对象 var SpeechRecognition=SpeechRecognition | | webkitSpeechRecognition; var recognition=新的SpeechRecognition(); //这将在语音识别服务启动时运行 recognition.onstart=函数(){ action.innerHTML=“听,请说…”; }; recognition.onspeechend=函数(){ action.innerHTML=“停止收听,希望您完成…”; 识别。停止(); } //这在语音识别服务返回结果时运行 recognition.onresult=函数(事件){ var转录本=事件。结果[0][0]。转录本; var置信度=事件。结果[0][0]。置信度; output.innerHTML=“Text:“+transcript+”
置信度:“+Confidence*100+”; output.classList.remove(“隐藏”); }; //开始识别 识别。开始(); }
它在PyQtWebEngine上不起作用 如何让它工作

我搜索了一下,发现只有基于chromium的浏览器支持语音识别


PyQtWebEngine是基于Chromium的,那么如何使其工作

虽然Chromium中提供了此功能,但Qt已禁用此功能,如中所示。在Qt6的以下版本中,可能会启用该功能