SpeechRecognitionResultList
Ограниченная доступность
Эта функция не относится к Baseline, так как она не работает во всех широко используемых браузерах.
Интерфейс SpeechRecognitionResultList API веб-речи представляет собой список объектов SpeechRecognitionResult, или один объект, если результаты собираются в режиме non-continuous.
Свойства экземпляра
-
SpeechRecognitionResultList.lengthТолько для чтения -
Возвращает длину «массива» — количество объектов
SpeechRecognitionResultв списке.
Методы экземпляра
SpeechRecognitionResultList.item-
Стандартный getter, который позволяет получить доступ к объектам
SpeechRecognitionResultв списке с помощью синтаксиса массива.
Примеры
Этот код взят из нашего примера изменения цвета речи.
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;
};
Спецификации
| Спецификация |
|---|
| API веб-речи # speechreco-resultlist |
Совместимость с браузерами
| Рабочие столы | Мобильные устройства | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari на iOS | Samsung Internet | WebView Android | |
SpeechRecognitionResultList |
33 | 79 | Нет | Нет | 14.1 | 33 | Нет | Нет | 14.5 | 2.0 | 4.4.3 |
item |
33 | 79 | Нет | Нет | 14.1 | 33 | Нет | Нет | 14.5 | 2.0 | 4.4.3 |
length |
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/SpeechRecognitionResultList