Webkitspeechrecognition on JavaScript Android Chrome

I'm using a simple voice to detect text through webkitspeechrecognition. This code works well on the windows desktop. However - on the Android Chrome browser - when starting the detection, the microphone on the Android status bar will only display for 1 or 2 seconds. If there is no voice activity - it will turn off and voice recognition will stop. If I click start, I can speak very fast, It will always be. Do you have any ideas to make Android microphones available at any time?

     if ('webkitSpeechRecognition' in window) {

          var recognition = new webkitSpeechRecognition();

            recognition.continuous = true;
            recognition.interimResults = true;

            recognition.onstart = function () {
                $("#status").html("Status: Recording...");
                recognizing = true;
            };

            recognition.onerror = function (event) {
                alert(event.error);
            };

            recognition.onend = function() {
                recognizing = false;
            };

          recognition.onresult = function(event) {
            var interim_transcript = '';
            for (var i = event.resultIndex; i < event.results.length; ++i) {
              if (event.results[i].isFinal) {
                final_transcript += event.results[i][0].transcript;
              } else {
                interim_transcript += event.results[i][0].transcript;
              }
            }
            final_transcript = capitalize(final_transcript);
            $("#final_span").html(linebreak(final_transcript));
            $("#interim_span").html(linebreak(interim_transcript));

          };

      }

resolvent:

When I tried to establish hands - free interaction with webvr, I was looking for a solution

https://codepen.io/bryik/pen/mErOOR?editors=0010 It only beeps at least once, but after some tests, I noticed that each click / tap triggers a recognized "prompt tone" again

Older resources give me great hope, let annyang( https://github.com/TalAter/annyang )Can work:

https://github.com/cvan/webvr-holodeck/issues/22 But I think it's just a phone call

recognition.onend = function() {
    console.info("voice recognition ended, restarting...");
    recognition.start();
}

In the recognition.onend callback. Therefore, on Android chrome, you may encounter a recognition prompt every second

Finally, MDN doesn't really say whether it can be in Android chrome( https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition )Continuous recognition on, but every example I've seen doesn't provide continuous mode on Android (at least on CyanogenMod lollipop)

//Editor, if you have a look https://www.microsoft.com/cognitive-services/en-us/speech-api , they will continue to gain recognition in some way, but I can't find anything in their source code

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>