JamesBrill / react-speech-recognition

💬Speech recognition for your React app
https://webspeechrecognition.com/
MIT License
695 stars 122 forks source link

Recognition has stopped working #13

Closed CygnusBell closed 5 years ago

CygnusBell commented 5 years ago

Hi, I've been using this for about 8 months now and it's worked great, but all of a sudden it won't work for me.

In my main app as well as just creating a simple app with just the getting started code.

It's not throwing an error or anything, the app compiles fine but then just does nothing in the browser.

Please advise. I know this is kind of ambiguous but I'm not sure what other info I can provide. Would appreciate any info greatly :)

JamesBrill commented 5 years ago
CygnusBell commented 5 years ago

Version: 1.1.0 Options: none, just the default. Console.log for these items... console.log(transcript); console.log(resetTranscript); console.log(browserSupportsSpeechRecognition);

returns "True", a blank line, and a function...

"ƒ () { interimTranscript = ''; finalTranscript = ''; _this.disconnect('RESET'); _this.setState({ interimTranscript: interimTranscript, finalTranscript: finalTran…"

Haha, no, not offline, you made that clear it's not possible :) Even in that case though it gave an error, this is just nothing.

Here is the full code of the app I'm trying to make work now. It was just taken from a stack exchange sample file.

import React, {Component } from 'react' import SpeechRecognition from 'react-speech-recognition'

class Dictaphone extends Component { render() { const { transcript, resetTranscript, browserSupportsSpeechRecognition } = this.props

    if (!browserSupportsSpeechRecognition) {
        return null
    }

    return (
        <div>
            <button onClick={resetTranscript}>Reset</button>
            <span>{transcript}</span>
        </div>
    )
}

}

export default SpeechRecognition(Dictaphone)

JamesBrill commented 5 years ago

I have used this same example code using version 1.1.0 and it behaves as normal.

When you run the app, do you see the red recording icon in your Chrome tab?

Screen Shot 2019-03-28 at 22 06 58
CygnusBell commented 5 years ago

No. I used to, but now for some reason it doesn't. I must've done something to goof it up, but not sure how to track it down since it was working last time I ran it about 3 weeks ago.

JamesBrill commented 5 years ago

To help me determine if this is a bug in 1.1.0 (which was released last week), can you revert back to 1.0.7 and see if you still get the issue?

JamesBrill commented 5 years ago

Hard-code the version with:

"react-speech-recognition": "1.0.7",

in your package.json and then run npm install.

JamesBrill commented 5 years ago

Another test to see if the Web Speech API is working in your browser:

JamesBrill commented 5 years ago

Another possibility is that you accidentally blocked your app from using your microphone in Chrome. If that is the case, you will see this icon in the right-hand side of your address bar:

Screen Shot 2019-03-28 at 22 16 21
CygnusBell commented 5 years ago

Using 1.0.7 did not fix. It's not the blocked microphone, checked that earlier.

When I try to run...

const recognition = new webkitSpeechRecognition(); recognition.start();

I get...

undefined

JamesBrill commented 5 years ago

When I try to run...

const recognition = new webkitSpeechRecognition(); recognition.start();

I get...

undefined

Yes, but does the recognition start and the red icon appear on your tab?

CygnusBell commented 5 years ago

No

JamesBrill commented 5 years ago

Which browser are you using?

CygnusBell commented 5 years ago

Google Chrome Version 73.0.3683.86 (Official Build) (64-bit)

JamesBrill commented 5 years ago

I have the same version and the two lines of code I posted above turned on the recognition. Web Speech API isn't working in your browser for some reason.

Two thoughts:

CygnusBell commented 5 years ago

gonna restart whole computer again, and browser, and then test mic, will be back with results.

JamesBrill commented 5 years ago

Haha drastic measures indeed! 😄 I look forward to the results.

CygnusBell commented 5 years ago

still not working :(

I restarted computer, restarted chrome and disabled all extensions... I gotta be doing something really stupid to make this not work lol

CygnusBell commented 5 years ago

oh and mic seems to be working, did a test record and the test setup in system prefs

JamesBrill commented 5 years ago

And to double-check, when you run

const recognition = new webkitSpeechRecognition();
recognition.start();

in a new tab, you do not see the flashing red recording icon in your tab?

CygnusBell commented 5 years ago

correct.

JamesBrill commented 5 years ago

What properties are on your recognition object? Just run

const recognition = new webkitSpeechRecognition();
recognition

Do you see an object like this?

Screen Shot 2019-03-28 at 22 40 21
CygnusBell commented 5 years ago

Screen Shot 2019-03-28 at 3 41 17 PM

JamesBrill commented 5 years ago

Did you instantiate it first?

JamesBrill commented 5 years ago
const recognition = new webkitSpeechRecognition();
recognition
CygnusBell commented 5 years ago

Screen Shot 2019-03-28 at 3 43 27 PM

JamesBrill commented 5 years ago

And when you run recognition.start(), no flashing icon... Weird.

Here's a good test: try this website https://www.cs.cmu.edu/~dst/SpeechDemo/

CygnusBell commented 5 years ago

yeah, super weird.

Screen Shot 2019-03-28 at 3 45 46 PM

This is interesting, it's saying not allowed even though in site settings it's set to "ask" and when I toggle it to "allowed" it still says not allowed. I wonder if there's some global permission I messed up at some point.

JamesBrill commented 5 years ago

Could you screenshot the thing that says the microphone is not allowed?

CygnusBell commented 5 years ago

Screen Shot 2019-03-28 at 3 49 34 PM

JamesBrill commented 5 years ago

I'm pulling at straws here, but is it possible that Chrome itself is blocked by your operating system from using the microphone? You mentioned System Preferences earlier, so I guess you're using a Mac. Maybe check this out? https://support.apple.com/en-gb/guide/mac-help/control-access-to-your-microphone-on-mac-mchla1b1e1fe/mac

JamesBrill commented 5 years ago

Though that link says you'd get prompted if the app tried to access the microphone again...

CygnusBell commented 5 years ago

THAT WAS IT!!!!!

THANKS FOR GRASPING THE STRAWS!!!

I was googling for hours for something like this but just kept coming across stuff about SSLs.

I guess this was in the system update and I just had no idea it was even a thing.

AGAIN THANK YOU SO MUCH (and sorry it had nothing to do with your component really).

CygnusBell commented 5 years ago

Though that link says you'd get prompted if the app tried to access the microphone again...

Yeah, it says that, but there was no such prompt lol hence having no idea where to check. Thank you again!

JamesBrill commented 5 years ago

Glad to hear you're unblocked! This was fun. 😄