File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
types/dom-speech-recognition Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const speechRecognition2: SpeechRecognition = {
3636 interimResults : false ,
3737 lang : "eng" ,
3838 maxAlternatives : 2 ,
39+ processLocally : true ,
3940 onaudioend : null ,
4041 onaudiostart : null ,
4142 onend : null ,
@@ -84,3 +85,13 @@ const speechRecognitionErrorEventInit: SpeechRecognitionErrorEventInit = {
8485 message : "abcde" ,
8586} ;
8687const speechRecognitionErrorEvent = new SpeechRecognitionErrorEvent ( "type" , speechRecognitionErrorEventInit ) ;
88+
89+ const speechRecognitionOptions : SpeechRecognitionOptions = {
90+ langs : [ "en-GB" ] ,
91+ processLocally : true ,
92+ } ;
93+
94+ ( async ( ) => {
95+ const availability : AvailabilityStatus = await SpeechRecognition . available ( speechRecognitionOptions ) ;
96+ const installOutcome : boolean = await SpeechRecognition . install ( speechRecognitionOptions ) ;
97+ } ) ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ interface SpeechRecognition extends EventTarget {
2020 interimResults : boolean ;
2121 lang : string ;
2222 maxAlternatives : number ;
23+ processLocally : boolean ;
2324 onaudioend : ( ( this : SpeechRecognition , ev : Event ) => any ) | null ;
2425 onaudiostart : ( ( this : SpeechRecognition , ev : Event ) => any ) | null ;
2526 onend : ( ( this : SpeechRecognition , ev : Event ) => any ) | null ;
@@ -56,7 +57,25 @@ interface SpeechRecognition extends EventTarget {
5657 ) : void ;
5758}
5859
59- declare var SpeechRecognition : { prototype : SpeechRecognition ; new ( ) : SpeechRecognition } ;
60+ // https://wicg.github.io/speech-api/#dictdef-speechrecognitionoptions
61+ interface SpeechRecognitionOptions {
62+ langs : string [ ] ;
63+ processLocally : boolean ;
64+ }
65+
66+ type AvailabilityStatus =
67+ | "unavailable"
68+ | "downloadable"
69+ | "downloading"
70+ | "available" ;
71+
72+ // https://webaudio.github.io/web-speech-api/#speechrecognition
73+ declare var SpeechRecognition : {
74+ prototype : SpeechRecognition ;
75+ new ( ) : SpeechRecognition ;
76+ available ( options : SpeechRecognitionOptions ) : Promise < AvailabilityStatus > ;
77+ install ( options : SpeechRecognitionOptions ) : Promise < boolean > ;
78+ } ;
6079
6180// https://wicg.github.io/speech-api/#speechrecognitionevent
6281interface SpeechRecognitionEventInit extends EventInit {
You can’t perform that action at this time.
0 commit comments