问题描述
我目前正在使用我的项目中的Google Web Speech API。在桌面上一切正常,但每当我尝试在Chrome浏览器的移动设备上使用我的webapp或Google Googles API演示程序时,都会出现几次重新出现的字词:
I'm currently working with the Google Web Speech API in my project. Everything is working fine on desktop, but whenever I try to use my webapp or Googles API Demo on mobile with Chrome, the recocnized words appear several times:
是否有任何修复或者是否有任何容易使用替代品?
Is there any fix for that or are there any easy to use alternatives?
推荐答案
我遇到了同样的问题,并搜索了网络,但没有发现溶剂。所以我检查了代码,这个重复的最终结果问题是由
I had the same issue and searched the net but found no sollution. So I checked the code and this repeating the final results issue is caused by
final_transcript += event.results[i][0].transcript;
消除'+'即可。
recognition.onresult = function(event) {
var interim_transcript = '';
if (typeof(event.results) == 'undefined') {
recognition.onend = null;
recognition.stop();
upgrade();
return;
}
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.innerHTML = linebreak(final_transcript);
interim_span.innerHTML = linebreak(interim_transcript);
if (final_transcript || interim_transcript) {
showButtons('inline-block');
}
};
也许这与中期业绩相同。我不需要他们,所以我没有检查。
Maybe it's the same hack on the the interim results. I won't need them so I didn't checked that.
这篇关于在移动设备上使用Google Web Speech API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!