SpeechRecognitionResult: свойство isFinal
Ограниченная доступность
Эта функция не относится к Baseline, так как она не работает во всех широко используемых браузерах.
Свойство isFinal только для чтения интерфейса SpeechRecognitionResult — это булево значение, указывающее, является ли этот результат окончательным (true) или нет (false) — если да, то это последний раз, когда будет возвращен этот результат; если нет, то этот результат является промежуточным и может быть обновлён позже.
Значение
Булево значение.
Примеры
recognition.onresult = (event) => {
// The SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object
// The SpeechRecognitionResultList object contains SpeechRecognitionResult objects.
// It has a getter so it can be accessed like an array
// The first [0] returns the SpeechRecognitionResult at position 0.
// Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects
// that contain individual results.
// These also have getters so they can be accessed like arrays.
// The second [0] returns the SpeechRecognitionAlternative at position 0.
// We then return the transcript property of the SpeechRecognitionAlternative object
const color = event.results[0][0].transcript;
diagnostic.textContent = `Result received: ${color}.`;
bg.style.backgroundColor = color;
console.log(event.results[0].isFinal);
};
Спецификации
| Спецификация |
|---|
| Web Speech API # dom-speechrecognitionresult-isfinal |
Совместимость с браузерами
| Рабочий стол | Мобильные устройства | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox для Android | Opera Android | Safari на iOS | Samsung Internet | WebView Android | |
isFinal |
33 | 79 | Нет | Нет | 14.1 | 33 | Нет | Нет | 14.5 | 2.0 | 4.4.3 |
См. также
© 2005–2024 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionResult/isFinal