sunboykenneth / react-native-voicebox-speech-rec

A powerful speech recognition library for React Native applications, enabling real-time speech-to-text transcription.
MIT License
16 stars 2 forks source link

Microphone restarts every 5-15 seconds. #5

Open alexzborovskii opened 5 months ago

alexzborovskii commented 5 months ago

Hi! Don't see this action in demo-video in the description, so probably it's not expected behavior? Microphone is restarting every 5-15 seconds, what influences recognition quality and makes imposiible to listen something else with the phone (listen music, watch youtube etc.).

mic_restarting

alexzborovskii commented 5 months ago

ok, now I see where it goes from. web speech api stops after few seconds of silence and recognition is restarting here: \node_modules\react-native-voicebox-speech-rec\src\static\speechRecScript.ts 66 line:

recognition.addEventListener("end", () => {
          // If the speech recognition is ended because the speech rec engine decided that
          // the user finishes speaking (e.g., user kept silent for a few seconds), we restart
          // the speech rec process
          if (!isManualStop) {
            recognition.start();
          } else {
            isListening = false;

            window.ReactNativeWebView.postMessage(
              JSON.stringify({
                type: "SpeechRecognitionEnd",
                data: transcriptResult,
              })
            );
          }
        });

So now I'm looking for the way to disable the stopping rule...