I've tried using say js with the following code:
let voices = await say.getInstalledVoices((e, v) => {console.log(v)});
console.log('voices=', voices);
Although the console.log in the callback function returns an array of voices, the voices variable returns a null.
I've had a go at wrapping the call in a promise and got a similar result.
Surely there's a simple one line way of getting those voices? I'm happy to use something other than say to do so.
You should not use await for the method.
The method say.getInstalledVoices
returns void
Just use the following syntax to get a list of the available voices:
const say = require('say');
function getVoices() {
return new Promise((resolve) => {
say.getInstalledVoices((err, voice) => {
return resolve(voice)
})
})
}
async function usingVoices() {
const voicesList = await getVoices();
console.log(voicesList)
}
usingVoices()
You can use the following syntax and do whatever you want to in usingVoices()
method