I have been trying for several hours to do this electronic speech recognition. The following code works in a normal browser:
if (window.SpeechRecognition === null ){
console.log("Speech Recognition is not supported.");
}else {
let recognizer = new window.SpeechRecognition();
recognizer.continuous = true;
recognizer.lang = "en-US";
recognizer.language = "English";
recognizer.onresult = function (ev){
console.log("Recognition result: ", event);
displayVoice.value == "";
}
recognizer.onerror = function (ev){
console.log("Recognition error: ", ev);
}
recognizer.start();
}
But when switching to electron, I get the following:

It means:
The network connection required to complete the recognition failed. (taken from MDN )
I have GOOGLE_API_KEY
installed in main.js
.
process.env.GOOGLE_API_KEY = 'NIzaadwINWVhlqbjjklajwdBp2zjcFxnD3O3cBwc'; - (it false stuff don't worry).
// process.env.GOOGLE_DEFAULT_CLIENT_ID = "95131180798735604-4k0pfsc6g.apps.googleusercontent.com"
// process.env.GOOGLE_DEFAULT_CLIENT_SECRET = "2kkkWCawzzlawuruhvdddwd_F1nqwFMUklUjYUTsft"
const path = require('path');
const url = require('url');
const {app, BrowserWindow} = require('electron');
...
There were several questions in this thread , I tried all of them.
here
here
and here and much more.
The idea of ββsetting up an environment variable is explained here .
I also found something interesting that might be relevant.
, :

Chrome.
, Chrome . (Chrome google )
env - Chrome .. . .
, . . , .
, ? .
UPDATE
, SpeechRecognition.serviceURI chrome - , . - chrome.