What I learned on this mini-project.
This is an interface for the Web Speech API. It contains the content that the speech service will read, as well as options that can be configured, such as language
and pitch
.
https://gist.github.com/42f72f3c149a214878b25254e2d6af1f
voiceschanged
- This event listener can be used to attach an event to add voices to use.getVoices()
- Will extract the voices on the device being used as an array
This is the controller interface for the speech service, which can be used to get information about the voices available, on your particular device.
It can also be used to start and pause the speech.
https://gist.github.com/0f561e3b28f6ba5167cf56d2ec97fbca
Above, are example properties and methods that can be used to alter the state of the speech device.
At times you may want to provide a parameter to a function to be used in an event listener. Unfortunately, doing this within a traditional function call will result in it being run on page load.
Using an anonymous function, you can avoid this problem
https://gist.github.com/195136e3b3c9df3351aa9fd7b5d669db
One caveat to this is that a new function will be created. Relying on this approach can cause unnecessary overhead to your code, which could have negative implications on your websites speed and efficiency.