title: SpeechRecognition network error when working with electron / chromium browser
body: <p>I'm trying for hours to make this electron speech recognition work. The following code works in normal browser : </p>
  
  <pre><code>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();
    }
  </code></pre>
  
  <p>But when switching to electron i get this: </p>
  
  <p><a href="https://i.stack.imgur.com/pkdGg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pkdGg.png" alt="SpeechRecognition network error when working with electron / chromium browser"></a></p>
  
  <p>This means:</p>
  
  <blockquote>
    <p>Network communication required for completing the recognition failed. (taken <a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionError/error" rel="noreferrer">from MDN</a>)</p>
  </blockquote>
  
  <p>I have the <code>GOOGLE_API_KEY</code> set up in <code>main.js</code>.</p>
  
  <pre><code>process.env.GOOGLE_API_KEY = 'NIzaadwINWVhlqbjjklajwdBp2zjcFxnD3O3cBwc'; - (it's 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');
  ...
  </code></pre>
  
  <p><strong>There have been a number of questions on this topic</strong>, i tried them all.
  <a href="https://stackoverflow.com/questions/39835083/webkitspeechrecognition-throws-error-network">here</a> 
  <a href="https://stackoverflow.com/questions/36866862/how-to-solve-google-speech-recognition-network-error">here</a>
  and <a href="https://github.com/electron-userland/electron-prebuilt/issues/196" rel="noreferrer">here</a> and many more.</p>
  
  <p>The environment variable setup idea is explained <a href="https://github.com/electron/electron/blob/master/docs/api/environment-variables.md" rel="noreferrer">here</a>.</p>
  
  <p>Also i discovered something interesting that might be relevant.</p>
  
  <p>When I changed the environment variables as suggested <a href="https://stackoverflow.com/questions/39835083/webkitspeechrecognition-throws-error-network">here</a>:
  <a href="https://i.stack.imgur.com/3xMKF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3xMKF.png" alt="enter image description here"></a></p>
  
  <p>But then the speech recognition stopped working in the normal Chrome browser.
  I think it overrides the default Chrome key. (Chrome it uses google servers to do the recognition)</p>
  
  <p>I removed back the env variables - Chrome works again.. electron doesn't. I have billing enabled for this keys. </p>
  
  <p>I can't believe that everybody failed to integrate this feature in electron. Speech recognition is important. I have no idea what else i should be doing. </p>
  
  <p><strong>Is it rely not possible to do speech recognition in electron?</strong> Then what i'm missing here..</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>i see that <a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/serviceURI" rel="noreferrer">SpeechRecognition.serviceURI</a> was removed form chrome - looks like this parameter was intended for implementing a custom speech recognition solution. I found this thread - <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/mUe4NM5xEzk" rel="noreferrer">why was serviceURI removed from chrome</a>. </p>