Audio from JavaScript doesn't play

I made something in JavaScript that is supposed to play audio from a URL when you click on a button. The audio works when I test the .HTML file directly from my computer, but the audio won't play when I use it on my website with the embed object. Does anyone know a fix for this? Here's how I have it set up.

<button onclick="playSound()">Play</button>
<script>
    function playSound() {
        var url = ("https://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=3&client=tw-ob&q=Hello&tl=en")
        var audio = new Audio(url);
        audio.play();
    }
</script>
1,271 Views
Message 1 of 2
Report Inappropriate Content
1 REPLY 1

@424Games

You don't have the url of your audio file defined - 

new Audio(url); 
1,265 Views
Message 3 of 2
Report Inappropriate Content