Android Chrome浏览器上的webkitSpeechRecognition [英] webkitSpeechRecognition on Android Chrome

查看:150
本文介绍了Android Chrome浏览器上的webkitSpeechRecognition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过webkitSpeechRecognition使用简单的语音对文本进行检测. 此代码在Windows桌面上效果很好. 但是-在 Android Chrome浏览器上-开始检测时,Android状态栏上的麦克风仅显示1或2秒.如果没有语音活动-它会关闭,并且语音识别会停止.如果在单击开始"后确实说得很快,它会一直保持下去. 有什么想法可以随时使Android麦克风可用吗?

I'm using a simple Speech to text detection with webkitSpeechRecognition. This code works great on Windows Desktop. But - on Android Chrome browser - When starting detection, the microphone on the Android status bar shows only for 1 or 2 seconds. If there is no voice activity - it turns off and the voice recognition stops. If I do speak very fast after clicking "Start", it stays on. Any ideas how to make the Android microphone available at all 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));

          };

      }

推荐答案

在尝试与WebVR建立免提交互时,我自己为此寻求了解决方案.

I looked for a solution to this myself as I am trying to build a hands-free interaction with WebVR.

https://codepen.io/bryik/pen/mErOOR?editors=0010 至少只发出一次哔声,但是经过一些测试,我注意到,每次单击/轻按都会再次触发识别的提示音".

https://codepen.io/bryik/pen/mErOOR?editors=0010 at least only beeps once, but after a bit of testing I noticed, that the 'beep' for recognition triggers again on every click/tap.

较旧的资源给我带来了希望,annyang( https://github.com/TalAter/annyang )可能会起作用:

An older resource gave me good hope, that annyang (https://github.com/TalAter/annyang) might work:

https://github.com/cvan/webvr-holodeck/issues/22 但是在这里,我猜它也只叫

https://github.com/cvan/webvr-holodeck/issues/22 But here I guess it's also only calling

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

在ognition.onend回调中为

.因此在android chrome上,您可能每隔一秒钟就会遇到识别蜂鸣声...

in the recognition.onend callback. So on android chrome you might encounter recognition beeps every other second...

最后,MDN并未真正说明是否可以在android chrome上进行连续识别(

In the end, MDN doesn't really state if it's possible to have continuous recognition on android chrome (https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition), but every example I looked at didn't quite offer continuous mode on android (at least on CyanogenMod Lollipop)

//编辑,如果您查看 https://www.microsoft.com/cognitive-services/en-us/speech-api ,他们以某种方式设法获得了持续的认可,但是我在他们的源代码中找不到任何东西...

// edit if you have a look at https://www.microsoft.com/cognitive-services/en-us/speech-api , they somehow manage to have continuous recognition but I can't find anything in their source code...

这篇关于Android Chrome浏览器上的webkitSpeechRecognition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆