Reputation: 21
I wanted to write a simple voice recognition app on electron.
I already tried it as a simple webpage in chrome, where everything worked perfectly fine. In electron however I dont get any console outputs.
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.addEventListener('result', e => {
console.log(e.results)
})
recognition.start();
The output that should appear (and appeared in Chrome) is:
I would really appreciate any help.
Upvotes: 2
Views: 1111
Reputation: 4103
SpeechRecognition is a Google proprietary technology and it's using a a Google API to make an HTTP request. Chrome has an API_KEY
but you have to specify your own Google API_KEY
in your electron process environment variables. You have the same issues with the navigator.geolocation
API: https://github.com/electron/electron/issues/7306
In your main.js file, before to call the SpeechRecognition API:
process.env.GOOGLE_API_KEY = "<GOOGLE API KEY>";
Upvotes: 1