speech-api.idl (7009B)
1 // 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://webaudio.github.io/web-speech-api/) 5 6 [SecureContext, Exposed=Window] 7 interface 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 attribute boolean processLocally; 17 attribute ObservableArray<SpeechRecognitionPhrase> phrases; 18 19 // methods to drive the speech interaction 20 undefined start(); 21 undefined start(MediaStreamTrack audioTrack); 22 undefined stop(); 23 undefined abort(); 24 static Promise<AvailabilityStatus> available(SpeechRecognitionOptions options); 25 static Promise<boolean> install(SpeechRecognitionOptions options); 26 27 // event methods 28 attribute EventHandler onaudiostart; 29 attribute EventHandler onsoundstart; 30 attribute EventHandler onspeechstart; 31 attribute EventHandler onspeechend; 32 attribute EventHandler onsoundend; 33 attribute EventHandler onaudioend; 34 attribute EventHandler onresult; 35 attribute EventHandler onnomatch; 36 attribute EventHandler onerror; 37 attribute EventHandler onstart; 38 attribute EventHandler onend; 39 }; 40 41 dictionary SpeechRecognitionOptions { 42 required sequence<DOMString> langs; 43 boolean processLocally = false; 44 }; 45 46 enum SpeechRecognitionErrorCode { 47 "no-speech", 48 "aborted", 49 "audio-capture", 50 "network", 51 "not-allowed", 52 "service-not-allowed", 53 "language-not-supported", 54 "phrases-not-supported" 55 }; 56 57 enum AvailabilityStatus { 58 "unavailable", 59 "downloadable", 60 "downloading", 61 "available" 62 }; 63 64 [SecureContext, Exposed=Window] 65 interface SpeechRecognitionErrorEvent : Event { 66 constructor(DOMString type, SpeechRecognitionErrorEventInit eventInitDict); 67 readonly attribute SpeechRecognitionErrorCode error; 68 readonly attribute DOMString message; 69 }; 70 71 dictionary SpeechRecognitionErrorEventInit : EventInit { 72 required SpeechRecognitionErrorCode error; 73 DOMString message = ""; 74 }; 75 76 // Item in N-best list 77 [SecureContext, Exposed=Window] 78 interface SpeechRecognitionAlternative { 79 readonly attribute DOMString transcript; 80 readonly attribute float confidence; 81 }; 82 83 // A complete one-shot simple response 84 [SecureContext, Exposed=Window] 85 interface SpeechRecognitionResult { 86 readonly attribute unsigned long length; 87 getter SpeechRecognitionAlternative item(unsigned long index); 88 readonly attribute boolean isFinal; 89 }; 90 91 // A collection of responses (used in continuous mode) 92 [SecureContext, Exposed=Window] 93 interface SpeechRecognitionResultList { 94 readonly attribute unsigned long length; 95 getter SpeechRecognitionResult item(unsigned long index); 96 }; 97 98 // A full response, which could be interim or final, part of a continuous response or not 99 [SecureContext, Exposed=Window] 100 interface SpeechRecognitionEvent : Event { 101 constructor(DOMString type, SpeechRecognitionEventInit eventInitDict); 102 readonly attribute unsigned long resultIndex; 103 readonly attribute SpeechRecognitionResultList results; 104 }; 105 106 dictionary SpeechRecognitionEventInit : EventInit { 107 unsigned long resultIndex = 0; 108 required SpeechRecognitionResultList results; 109 }; 110 111 // The object representing a speech grammar. This interface has been deprecated and exists in this spec for the sole purpose of maintaining backwards compatibility. 112 [Exposed=Window] 113 interface SpeechGrammar { 114 attribute DOMString src; 115 attribute float weight; 116 }; 117 118 // The object representing a speech grammar collection. This interface has been deprecated and exists in this spec for the sole purpose of maintaining backwards compatibility. 119 [Exposed=Window] 120 interface SpeechGrammarList { 121 constructor(); 122 readonly attribute unsigned long length; 123 getter SpeechGrammar item(unsigned long index); 124 undefined addFromURI(DOMString src, 125 optional float weight = 1.0); 126 undefined addFromString(DOMString string, 127 optional float weight = 1.0); 128 }; 129 130 // The object representing a phrase for contextual biasing. 131 [SecureContext, Exposed=Window] 132 interface SpeechRecognitionPhrase { 133 constructor(DOMString phrase, optional float boost = 1.0); 134 readonly attribute DOMString phrase; 135 readonly attribute float boost; 136 }; 137 138 [Exposed=Window] 139 interface SpeechSynthesis : EventTarget { 140 readonly attribute boolean pending; 141 readonly attribute boolean speaking; 142 readonly attribute boolean paused; 143 144 attribute EventHandler onvoiceschanged; 145 146 undefined speak(SpeechSynthesisUtterance utterance); 147 undefined cancel(); 148 undefined pause(); 149 undefined resume(); 150 sequence<SpeechSynthesisVoice> getVoices(); 151 }; 152 153 partial interface Window { 154 [SameObject] readonly attribute SpeechSynthesis speechSynthesis; 155 }; 156 157 [Exposed=Window] 158 interface SpeechSynthesisUtterance : EventTarget { 159 constructor(optional DOMString text); 160 161 attribute DOMString text; 162 attribute DOMString lang; 163 attribute SpeechSynthesisVoice? voice; 164 attribute float volume; 165 attribute float rate; 166 attribute float pitch; 167 168 attribute EventHandler onstart; 169 attribute EventHandler onend; 170 attribute EventHandler onerror; 171 attribute EventHandler onpause; 172 attribute EventHandler onresume; 173 attribute EventHandler onmark; 174 attribute EventHandler onboundary; 175 }; 176 177 [Exposed=Window] 178 interface SpeechSynthesisEvent : Event { 179 constructor(DOMString type, SpeechSynthesisEventInit eventInitDict); 180 readonly attribute SpeechSynthesisUtterance utterance; 181 readonly attribute unsigned long charIndex; 182 readonly attribute unsigned long charLength; 183 readonly attribute float elapsedTime; 184 readonly attribute DOMString name; 185 }; 186 187 dictionary SpeechSynthesisEventInit : EventInit { 188 required SpeechSynthesisUtterance utterance; 189 unsigned long charIndex = 0; 190 unsigned long charLength = 0; 191 float elapsedTime = 0; 192 DOMString name = ""; 193 }; 194 195 enum SpeechSynthesisErrorCode { 196 "canceled", 197 "interrupted", 198 "audio-busy", 199 "audio-hardware", 200 "network", 201 "synthesis-unavailable", 202 "synthesis-failed", 203 "language-unavailable", 204 "voice-unavailable", 205 "text-too-long", 206 "invalid-argument", 207 "not-allowed", 208 }; 209 210 [Exposed=Window] 211 interface SpeechSynthesisErrorEvent : SpeechSynthesisEvent { 212 constructor(DOMString type, SpeechSynthesisErrorEventInit eventInitDict); 213 readonly attribute SpeechSynthesisErrorCode error; 214 }; 215 216 dictionary SpeechSynthesisErrorEventInit : SpeechSynthesisEventInit { 217 required SpeechSynthesisErrorCode error; 218 }; 219 220 [Exposed=Window] 221 interface SpeechSynthesisVoice { 222 readonly attribute DOMString voiceURI; 223 readonly attribute DOMString name; 224 readonly attribute DOMString lang; 225 readonly attribute boolean localService; 226 readonly attribute boolean default; 227 };