我正在使用Web Speech api,想知道是否有任何关于如何检测或添加标点符号(逗号或句点)的文档。
我的代码目前看起来像这样:
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onstart = function() {
recognizing = true;
};
recognition.onend = function() {
recognizing = false;
if (ignoreOnend) {
return;
}
if (!finalTranscript) {
return;
}
};
recognition.onresult = function(event) {
var interimTranscript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
finalTranscript += event.results[i][0].transcript;
} else {
interimTranscript += event.results[i][0].transcript;
}
}
finalTranscript = capitalize(finalTranscript);
finalSpan.innerHTML = linebreak(finalTranscript);
interimSpan.innerHTML = linebreak(interimTranscript);
};