SpeechRecognitionAlternative: свойство confidence
Ограниченная доступность
Эта функция не относится к Baseline, так как она не работает во всех широко используемых браузерах.
Чтение-только свойство confidence интерфейса SpeechRecognitionResult возвращает числовое значение, оценивающее уверенность системы распознавания речи в правильности распознавания.
Примечание: Реализация confidence в Mozilla всё ещё находится в разработке — в настоящее время она всегда возвращает 1.
Значение
Число от 0 до 1.
Примеры
Этот код взят из нашего примера Изменение цвета речи.
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(`Confidence: ${event.results[0][0].confidence}`);
};
Спецификации
Совместимость с браузерами
| Рабочие столы | Мобильные устройства | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox для Android | Opera Android | Safari на iOS | Samsung Internet | WebView Android | |
confidence |
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/SpeechRecognitionAlternative/confidence