If you read about webkitSpeechRecognition, you will notice that the original way to retrieve the available voices in Google Chrome is an asynchronous method. So artyom allows you to retrieve the voices synchronously and asign it to a variable if you want.
If the function doesn't return anything at first time, the computer may be so slow. Artyom gives maximum optimization in order to retrieve the voices quickly anyway (the voices are automatically retrieven when the script is loaded in the document and the speech Synthesis API is available), if it fails you can follow these steps to solve the issue.
- Include artyom in the header tag of your document.
- Prevent from using the functions of artyom that needs the voices with DOMReady listeners. Use when the window is loaded instead (window.onload in javascript or $(window).load() if you use jQuery)
Example
The usage of the following code should display an array with the supported voices of the browser in the console:
console.log(artyom.getVoices());
You can use the following snippet to show the names of the voices in the console:
var voices = artyom.getVoices();
for(var i = 0;i < voices.length;i++){
var voice = voices[i];
console.log(voice.name);
}