Problem with speechSynthesisUtterance object

let speech = new SpeechSynthesisUtterance();

const setVoice = () => {
    let voices = speechSynthesis.getVoices();
    speech.voice = voices[25];
};

setVoice();

// utter the word
const sayWord = (string) => {
    speech.text = string;
    speechSynthesis.speak(speech);
};

sayWord("Keep going");

According to the code, the voice of the speech should change but it doesn’t. But when I call the setVoice() function once again, it works. Why is this happening? Why does it not work at the very first invocation.