Web Speech API

Web Speech API позволяет взаимодействовать с голосовыми интерфейсами в ваших веб приложениях. Web Speech API состоит из двух частей: SpeechSynthesis (Текст-в-Речь), и SpeechRecognition (Асинхронное распознавание речи)

Концепции и использование Web Speech

Web Speech API позволяет веб приложениям управлять голосовыми данными. Существует два компонента к этому API:

  • Распознавание голоса. Доступ обеспечивается через SpeechRecognition интерфейс, который в свою очередь обеспечивает возможность распознавать текст из входящего аудио потока (обычно через устройство распознавания речи в устройстве по умолчанию) и отвечать соответственно. Воспользовавшись конструктором интерфейса вы можете создать новый SpeechRecognition объект, у которого есть ряд событий для обнаружения начала речи через микрофон устройства. SpeechGrammar интерфейс предоставляет контейнер для определённого набора грамматики, которое ваше приложение должно использовать. Грамматика определяется с помощью JSpeech Grammar Format (JSGF.)
  • Доступ к синтезу речи осуществляется с помощью SpeechSynthesis интерфейса, компонент text-to-speech позволяет приложениям прочесть свой текстовый контент (обычно через дефолтный синтезатор речи устройства). В SpeechSynthesisVoice объектах есть различные типы голоса, и различным частям текста можно назначать SpeechSynthesisUtterance объекты. Можно начать воспроизведение передав их методу SpeechSynthesis.speak().

Для большей информации по использованию этих фич, смотрите Using the Web Speech API.

Интерфейсы Web Speech API

Распознавание речи

SpeechRecognition

The controller interface for the recognition service; this also handles the SpeechRecognitionEvent sent from the recognition service.

SpeechRecognitionAlternative

Представляет одно слово которое было распознано службой распознавания голоса.

SpeechRecognitionError

Представляет сообщения об ошибках из службы распознавания.

SpeechRecognitionEvent

The event object for the result and nomatch events, and contains all the data associated with an interim or final speech recognition result.

SpeechGrammar

Слова или шаблоны слов которые мы хотим чтобы служба распознавания распознала.

SpeechGrammarList

Представляет список объектов SpeechGrammar.

SpeechRecognitionResult

Представляет одно распознанное совпадение, которое может содержать несколько объектов SpeechRecognitionAlternative.

SpeechRecognitionResultList

Represents a list of SpeechRecognitionResult objects, or a single one if results are being captured in continuous mode.

Синтезирование речи

SpeechSynthesis

The controller interface for the speech service; this can be used to retrieve information about the synthesis voices available on the device, start and pause speech, and other commands besides.

SpeechSynthesisErrorEvent

Contains information about any errors that occur while processing SpeechSynthesisUtterance objects in the speech service.

SpeechSynthesisEvent

Contains information about the current state of SpeechSynthesisUtterance objects that have been processed in the speech service.

SpeechSynthesisUtterance

Represents a speech request. It contains the content the speech service should read and information about how to read it (e.g. language, pitch and volume.)

SpeechSynthesisVoice

Represents a voice that the system supports. Every SpeechSynthesisVoice has its own relative speech service including information about language, name and URI.

Window.speechSynthesis

Specced out as part of a [NoInterfaceObject] interface called SpeechSynthesisGetter, and Implemented by the Window object, the speechSynthesis property provides access to the SpeechSynthesis controller, and therefore the entry point to speech synthesis functionality.

Примеры

Web Speech API репозиторий на GitHub содержит примеры, показывающие распознавание и синтез речи.

Спецификации

Specification
Web Speech API

Совместимость с браузерами

api.SpeechRecognition

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
SpeechRecognition
SpeechRecognition() constructor
abort
audioend event
audiostart event
continuous
end event
error event
grammars
interimResults
lang
maxAlternatives
nomatch event
result event
soundend event
soundstart event
speechend event
speechstart event
start
start event
stop

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.
Requires a vendor prefix or different name for use.

api.SpeechSynthesis

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
SpeechSynthesis
cancel
getVoices
pause
paused
pending
resume
speak
speaking
voiceschanged event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Смотрите также