synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
947 stars 101 forks source link

Browser microphone throws an exception #150

Closed timaschew closed 4 years ago

timaschew commented 4 years ago

When clicking use browser microphone this is thrown in the browser console:

TranscribeSpeech.vue:258 Uncaught TypeError: Cannot read property 'getUserMedia' of undefined
    at u.getMicrophonePermission (TranscribeSpeech.vue:258)
    at n (vue.runtime.esm.js:2023)
    at HTMLInputElement.t._withTask.t._withTask (vue.runtime.esm.js:1822)

Happens on latest docker version and latest git commit via virtual-env.

synesthesiam commented 4 years ago

Which browser? I'm testing with Firefox 71 currently.

timaschew commented 4 years ago

I'm using macos and Brave.
But Firefox and Chrome isn't working as well, but this is because I'm serving via http (without ssl). This could be checked upfront with something like this:

if (window.location.protocol != 'https:') {
  alert("microphone is only allowed via https")
  return
}
synesthesiam commented 4 years ago

Oh, I remember reading about this. Gotta love that they basically ruined the use of the browser microphone. If I recall, it's supposed to still work on localhost at least.

timaschew commented 4 years ago

True, it's totally stupid to have these kind of restrictions for localhost.

gvs55 commented 4 years ago

This was the root of my issue as well. I was trying to test commands in the browser via http (as SSL / https is currently not functional).

You can workaround it by trusting the url specifically.

On Brave you can go to brave://flags/ and locate "Insecure origins treated as secure" , add the urls you want to be trusted and enable the option. After re-launching you should be able to use your microphone over http for the specified urls.

krisha commented 4 years ago

This is also a problem on Firefox if not running on localhost.

Related flags are "media.devices.insecure.enabled" and "media.getusermedia.insecure.enabled" in about:config

synesthesiam commented 4 years ago

So would everyone agree this is something that should just be addressed in the documentation?

gvs55 commented 4 years ago

I would agree. The docs or an FAQ. It's just one of those things that is confusing for new users. Certainly confused me for a little bit.

Probably should be noted too that this is only an issue if you're connecting via http, and not https.

krisha commented 4 years ago

Yes. I think showing an error message could be nice also.

synesthesiam commented 4 years ago

Browser microphone will be removed in 2.5. It's too much trouble to depend on the whims of browser vendors :(