JamesBrill / react-speech-recognition

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

Azure not working getting WebSocket connection to 'wss://us.stt.speech.microsoft.com failed: and this.recognition.stop is not a function #156

Open CaiIsProgrammer opened 1 year ago

CaiIsProgrammer commented 1 year ago

so im trying to polly fill azure like this

const SUBSCRIPTION_KEY ="";
const REGION = "US";

const { SpeechRecognition: AzureSpeechRecognition } =
  createSpeechServicesPonyfill({
    credentials: {
      region: REGION,
      subscriptionKey: SUBSCRIPTION_KEY,
    },
  });
SpeechRecognition.applyPolyfill(AzureSpeechRecognition);

and


const SUBSCRIPTION_KEY = "";
const REGION = "eastus2";

const { SpeechRecognition: AzureSpeechRecognition } =
  createSpeechServicesPonyfill({
    credentials: {
      region: REGION,
      subscriptionKey: SUBSCRIPTION_KEY,
    },
  });
SpeechRecognition.applyPolyfill(AzureSpeechRecognition);

but niether are working and yes i redacted my key

errors are

WebSocket connection to 'wss://us.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en&format=detailed&Ocp-Apim-Subscription-Key=XXXXX&X-ConnectionId=484734276B5C4B108A0623DDDC8C1044' failed: 

and


RecognitionManager.js:437 Uncaught (in promise) TypeError: this.recognition.stop is not a function
    at RecognitionManager.stop (RecognitionManager.js:437:1)
CaiIsProgrammer commented 1 year ago

using this to start and stop


  useEffect(() => {
    if (record) {
      if (volume > 10) {
        setIsPaused(false);
        setTime(0);
        if (!listening) {
          SpeechRecognition.startListening({ language: "en-US" });
        }
      } else if (time > 1000) {
        setTime(0);
        setIsPaused(true);
        SpeechRecognition.stopListening();
      }
    }
  }, [record, time]);
cedric-costa commented 11 months ago

using this to start and stop


  useEffect(() => {
    if (record) {
      if (volume > 10) {
        setIsPaused(false);
        setTime(0);
        if (!listening) {
          SpeechRecognition.startListening({ language: "en-US" });
        }
      } else if (time > 1000) {
        setTime(0);
        setIsPaused(true);
        SpeechRecognition.stopListening();
      }
    }
  }, [record, time]);

Did you manage to fix your problem? I'm having the exact same issue and can't seem to find the cause.