Problem with speechSynthesisUtterance object

let speech = new SpeechSynthesisUtterance();

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


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

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.