Stephane PAQUET PRO said 2 months ago on Text to Speech :
Improving the code for the setPreferredVoices function:

const preferredVoice = this.preferredVoices
  .map(name => voices.find(v => v.name === name))
  .find(Boolean);

if (preferredVoice) {
  Object.assign(this.utterance, {
    voice: preferredVoice,
    lang: preferredVoice.lang
  });
  console.log(`Selected voice: ${preferredVoice.name}`, `Selected lang: ${preferredVoice.lang}`);
}

it looks like Claude, Meta and O1-mini are all in agreement with this code ;-)