Continuous speech recognition with phonegap

蓝咒 提交于 2019-12-07 07:58:33

问题


I want to create app in phonegap with continuous speech recognition in Android and IOS. My app should wait for user voice and when he/she say "next", app should update screen and do some actions.

I find this plugin: https://github.com/macdonst/SpeechRecognitionPlugin and it works really fast. But after few seconds after voice recognition is started and there is no voice, speech recogniser stops. Is there any method or flag like isSpeechRecognizerAlive or any other solution? Or is it possible to run it as a service?

I'm also wondering that is there similar plugin on IOS and how to manage it :)


回答1:


This plugin is based on Web Speech API located here (https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#examples) Example 3 & 4 addresses you issue with

recognition.continuous = true

<textarea id="textarea" rows=10 cols=80></textarea>
  <button id="button" onclick="toggleStartStop()"></button>

  <script type="text/javascript">
    var recognizing;
    var recognition = new SpeechRecognition();
    recognition.continuous = true;
    reset();
    recognition.onend = reset;

    recognition.onresult = function (event) {
      for (var i = resultIndex; i < event.results.length; ++i) {
        if (event.results.final) {
          textarea.value += event.results[i][0].transcript;
        }
      }
    }

    function reset() {
      recognizing = false;
      button.innerHTML = "Click to Speak";
    }

    function toggleStartStop() {
      if (recognizing) {
        recognition.stop();
        reset();
      } else {
        recognition.start();
        recognizing = true;
        button.innerHTML = "Click to Stop";
      }
    }
  </script>

Also there is another plugin which does the continuous Speech recognition located here

https://github.com/daao87/ContinuousSpeechRecognizer

But is has some issues not solved yet. Though it works great (tested on Lollipop 5.1)



来源:https://stackoverflow.com/questions/21826520/continuous-speech-recognition-with-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!