blob: 74085481525c943296f023e94a6532e5bc9f5b15 [file] [log] [blame]
Victor Porof6e096922022-06-10 13:01:05 +00001// GENERATED CONTENT - DO NOT EDIT
2// Content was automatically extracted by Reffy into webref
3// (https://github.com/w3c/webref)
4// Source: Web Speech API (https://wicg.github.io/speech-api/)
5
6[Exposed=Window]
7interface SpeechRecognition : EventTarget {
8 constructor();
9
10 // recognition parameters
11 attribute SpeechGrammarList grammars;
12 attribute DOMString lang;
13 attribute boolean continuous;
14 attribute boolean interimResults;
15 attribute unsigned long maxAlternatives;
16
17 // methods to drive the speech interaction
18 undefined start();
19 undefined stop();
20 undefined abort();
21
22 // event methods
23 attribute EventHandler onaudiostart;
24 attribute EventHandler onsoundstart;
25 attribute EventHandler onspeechstart;
26 attribute EventHandler onspeechend;
27 attribute EventHandler onsoundend;
28 attribute EventHandler onaudioend;
29 attribute EventHandler onresult;
30 attribute EventHandler onnomatch;
31 attribute EventHandler onerror;
32 attribute EventHandler onstart;
33 attribute EventHandler onend;
34};
35
36enum SpeechRecognitionErrorCode {
37 "no-speech",
38 "aborted",
39 "audio-capture",
40 "network",
41 "not-allowed",
42 "service-not-allowed",
43 "bad-grammar",
44 "language-not-supported"
45};
46
47[Exposed=Window]
48interface SpeechRecognitionErrorEvent : Event {
49 constructor(DOMString type, SpeechRecognitionErrorEventInit eventInitDict);
50 readonly attribute SpeechRecognitionErrorCode error;
51 readonly attribute DOMString message;
52};
53
54dictionary SpeechRecognitionErrorEventInit : EventInit {
55 required SpeechRecognitionErrorCode error;
56 DOMString message = "";
57};
58
59// Item in N-best list
60[Exposed=Window]
61interface SpeechRecognitionAlternative {
62 readonly attribute DOMString transcript;
63 readonly attribute float confidence;
64};
65
66// A complete one-shot simple response
67[Exposed=Window]
68interface SpeechRecognitionResult {
69 readonly attribute unsigned long length;
70 getter SpeechRecognitionAlternative item(unsigned long index);
71 readonly attribute boolean isFinal;
72};
73
74// A collection of responses (used in continuous mode)
75[Exposed=Window]
76interface SpeechRecognitionResultList {
77 readonly attribute unsigned long length;
78 getter SpeechRecognitionResult item(unsigned long index);
79};
80
81// A full response, which could be interim or final, part of a continuous response or not
82[Exposed=Window]
83interface SpeechRecognitionEvent : Event {
84 constructor(DOMString type, SpeechRecognitionEventInit eventInitDict);
85 readonly attribute unsigned long resultIndex;
86 readonly attribute SpeechRecognitionResultList results;
87};
88
89dictionary SpeechRecognitionEventInit : EventInit {
90 unsigned long resultIndex = 0;
91 required SpeechRecognitionResultList results;
92};
93
94// The object representing a speech grammar
95[Exposed=Window]
96interface SpeechGrammar {
97 attribute DOMString src;
98 attribute float weight;
99};
100
101// The object representing a speech grammar collection
102[Exposed=Window]
103interface SpeechGrammarList {
104 constructor();
105 readonly attribute unsigned long length;
106 getter SpeechGrammar item(unsigned long index);
107 undefined addFromURI(DOMString src,
108 optional float weight = 1.0);
109 undefined addFromString(DOMString string,
110 optional float weight = 1.0);
111};
112
113[Exposed=Window]
114interface SpeechSynthesis : EventTarget {
115 readonly attribute boolean pending;
116 readonly attribute boolean speaking;
117 readonly attribute boolean paused;
118
119 attribute EventHandler onvoiceschanged;
120
121 undefined speak(SpeechSynthesisUtterance utterance);
122 undefined cancel();
123 undefined pause();
124 undefined resume();
125 sequence<SpeechSynthesisVoice> getVoices();
126};
127
128partial interface Window {
129 [SameObject] readonly attribute SpeechSynthesis speechSynthesis;
130};
131
132[Exposed=Window]
133interface SpeechSynthesisUtterance : EventTarget {
134 constructor(optional DOMString text);
135
136 attribute DOMString text;
137 attribute DOMString lang;
138 attribute SpeechSynthesisVoice? voice;
139 attribute float volume;
140 attribute float rate;
141 attribute float pitch;
142
143 attribute EventHandler onstart;
144 attribute EventHandler onend;
145 attribute EventHandler onerror;
146 attribute EventHandler onpause;
147 attribute EventHandler onresume;
148 attribute EventHandler onmark;
149 attribute EventHandler onboundary;
150};
151
152[Exposed=Window]
153interface SpeechSynthesisEvent : Event {
154 constructor(DOMString type, SpeechSynthesisEventInit eventInitDict);
155 readonly attribute SpeechSynthesisUtterance utterance;
156 readonly attribute unsigned long charIndex;
157 readonly attribute unsigned long charLength;
158 readonly attribute float elapsedTime;
159 readonly attribute DOMString name;
160};
161
162dictionary SpeechSynthesisEventInit : EventInit {
163 required SpeechSynthesisUtterance utterance;
164 unsigned long charIndex = 0;
165 unsigned long charLength = 0;
166 float elapsedTime = 0;
167 DOMString name = "";
168};
169
170enum SpeechSynthesisErrorCode {
171 "canceled",
172 "interrupted",
173 "audio-busy",
174 "audio-hardware",
175 "network",
176 "synthesis-unavailable",
177 "synthesis-failed",
178 "language-unavailable",
179 "voice-unavailable",
180 "text-too-long",
181 "invalid-argument",
182 "not-allowed",
183};
184
185[Exposed=Window]
186interface SpeechSynthesisErrorEvent : SpeechSynthesisEvent {
187 constructor(DOMString type, SpeechSynthesisErrorEventInit eventInitDict);
188 readonly attribute SpeechSynthesisErrorCode error;
189};
190
191dictionary SpeechSynthesisErrorEventInit : SpeechSynthesisEventInit {
192 required SpeechSynthesisErrorCode error;
193};
194
195[Exposed=Window]
196interface SpeechSynthesisVoice {
197 readonly attribute DOMString voiceURI;
198 readonly attribute DOMString name;
199 readonly attribute DOMString lang;
200 readonly attribute boolean localService;
201 readonly attribute boolean default;
202};