I have a small code
<!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> <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>
It does not work on PyQtWebEngine How to make it work.
I searched for it and found that only chromium based browser supports speech recogonition.
PyQtWebEngine is Chromium Based then How to make it work
Although this feature is available in chromium but it has been disabled by Qt as indicated in this report. Maybe in the following versions of Qt6 it will be enabled.