I want to generate a TTS dynamically based on the input language
<script>
audio = document.getElementById("audio");
lang = "en_US";
audio.innerHTML = `{{ tts ${lang} word }}`;
</script>
the previous script generates a tts element, but couldn’t interpret the interpolated variable, i.e. didn’t replace ${lang}
with its value.
there are some other issues here:
1- using let
or var
to define audio
causes the script not to run at all
let audio = ....
var audio = ....
audio = ... // only this works
2- using double quotations also causes the script not working
audio.innerHTML = "{{tts word}}"; //not working
audio.innerHTML = `{{tts word}}` // working