SpeechRecognition network error with electronic / chrome browser

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.interimResults = true;
    recognizer.start();
  }

But when switching to electron, I get the following:

SpeechRecognition network error with electronic / chrome browser

It means:

The network connection required to complete the recognition failed. (taken from MDN )

I have GOOGLE_API_KEYinstalled 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.

, : enter image description here

Chrome. , Chrome . (Chrome google )

env - Chrome .. . .

, . . , .

, ? .

UPDATE

, SpeechRecognition.serviceURI chrome - , . - chrome.

+4
1

, Chrome , 47, API- https. API Chrome WebRTC.

no-more-http-for-webrtc-on-chrome-only-https

+1

Source: https://habr.com/ru/post/1689078/


All Articles