#Hey everyone, in need of urgent help. So I have an electron app and I need to use speech recognition

53 messages · Page 1 of 1 (latest)

heady forge
#

it is chrome specific only

long notch
#

see the details I provided in my question

#

lemme paste the content here too

#

So I have an Electron app that uses the web speech API (SpeechRecognition) to take the user's voice, however, it's not working. The code:

if ("webkitSpeechRecognition" in window) {
    let SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
    let recognition = new SpeechRecognition();

    recognition.onstart = () => {
      console.log("We are listening. Try speaking into the microphone.");
    };

    recognition.onspeechend = () => {
      recognition.stop();
    };

    recognition.onresult = (event) => {
      let transcript = event.results[0][0].transcript;
      console.log(transcript);
    };

    recognition.start();
  } else {
    alert("Browser not supported.")
  }

It says We are listening... in the console, but no matter what you say, it doesn't give an output. On the other hand, running the exact same thing in Google Chrome works and whatever I say gets console logged out with the console.log(transcript); part. I did some more research and it turns out that Google has recently stopped support for the Web Speech API in shell-based Chromium windows (Tmk, everything that is not Google Chrome or MS Edge), so that seems to be the reason it is not working on my Electron app.

See: electron-speech library's end Artyom.js issue

So is there any way I can get it to work in Electron?

heady forge
#

electron do not have google api key for speech recognition

#

so you cant use it

long notch
long notch
heady forge
#

it is not chromium based

long notch
#

and Google Chrome

heady forge
#

edge and chrome is not chromium

long notch
#

all Chromium based browsers support it except shell-based ones like Electron

long notch
#

They are both Chromium-based web browsers.

#

Electron is Chromium based too but it's a shell-based Chromium browser which isn't supported for the web speech API anymore.

heady forge
#

they use gogle api key

long notch
#

See the links I included above.

long notch
# heady forge they use gogle api key

It's built into them, running the same speech recognition code in Google Chrome or MS Edge without an API key works, while it doesn't work in Electron.

#

See the link I included, they make this clear actually :)

heady forge
#

you can open issue on github

#

this is all what you can do for now

long notch
# heady forge you can open issue on github

It's not an issue, Google made the decision to disable the Web Speech API on shell-based Chromium browsers (Electron included) so that only Google Chrome, MS Edge, and other proper Chromium-based browsers can utilize it. So I am looking for another way to get user's speech in JavaScript Electron.

#

Wait, Discord is built with Electron too, right? @heady forge

heady forge
#

discord build electron from sources

long notch
heady forge
#

they able to add it

#

on electron build stage

long notch
#

Sorry, it's difficult to understand what you're trying to say.

#

Are you saying they don't use Electron or they do use Electron?

heady forge
#

discord use custom version of electron

long notch
#

How do they get the user's speech in voice chat?

#

like you click he VC channel and you can speak through your microphone and it detects your speech.

#

How does it do that?

heady forge
#

analyze audio data

long notch
#

and how do they get the audio data?

#

what API do they use?

#

can't be web speech API :/

#

coz it doesn't work with shell-based browsers as we know

heady forge
#

with navigator.mediaDevices.getUserMedia

long notch
long notch
#

Because if we can send it to the backend, then we would be able to use a backend-based service to analyze the speech of that user and return a response.

#

That's possible, right

#

?

heady forge
#

possible but too expensive

long notch
#

Jasper is a free backend service so we can send the audio stream to the python backend?

long notch
#

I am going to try and implement this

#

closing this for now, will let you know if any issue arrises if God wills.