Web_sys, SpeechSynthesis API, confused about conventions for instances


#1

I’m trying to use the JavaScript SpeechSynthesis API in web_sys. In the actual API, window.SpeechSynthesis is a singleton. You might, for instance, create a SpeechSynthesisUtterance then call window.SpeechSynthesis.speak(utterance) to speak it. You don’t need a SpeechSynthesis instance to do this.

But if you look at https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.SpeechSynthesis.html#method.speak, it appears to need &self as an initial argument, suggesting I need an instance of what in JavaScript is a singleton.

How am I meant to call this API? SpeechSynthesisUtterance is easy as it has a new method, but I don’t see something similar for SpeechSynthesis.

Thanks.