Text-to-Speech in Multiple Languages | XM Community
Question

Text-to-Speech in Multiple Languages

  • 9 June 2021
  • 1 reply
  • 35 views

Hello, I am trying to insert code for a text-to-speech function. However, my survey is based in English with select Spanish words. I tried using the solution posted here but it only picks up the English words and skips the Spanish words. Is there a way I can adjust this code or insert a second code to catch the second language?


1 reply

Userlevel 7
Badge +22

We need to split the text to speech into multiple parts based on the sequece of words. We can use the code from the question post for english and then for spanish use below code:
var msg = new SpeechSynthesisUtterance('Spanish text goes here.....');
  msg.lang = 'es-ES';
  window.speechSynthesis.speak(msg); 

Leave a Reply