This code should be very compatible (IE6 +) using WAVE:
<![if (!IE)|(gte IE 9)]> <audio id="speak" src="speak_a.wav" type="audio/wav"></audio> <a href="#" onclick="document.getElementById('speak').play()">Speak</a> <![endif]>
Another option using both mp3 / ogg and still very compatible:
<![if (!IE)|(gte IE 9)]> <audio id="speak"> <source src="speak_a.ogg" type="audio/ogg" /> <source src="speak_a.mp3" type="audio/mpeg" /> <a href="speak_a.mp3">Download speak_a.mp3 if you cannot play it</a> </audio> <a href="#" onclick="document.getElementById('speak').play()">Speak</a> <![endif]>
If you do not need to support IE9 before, the <audio> should be enough:
<audio id="speak"> <source src="speak_a.ogg" type="audio/ogg" /> <source src="speak_a.mp3" type="audio/mpeg" /> </audio> <a href="#" onclick="document.getElementById('speak').play()">Speak</a>
Another old way to play audio:
<object data="speak_a.wav" type="audio/wav"> <embed src="speak_a.wav"></embed> </object>
And you can also use third-party libraries like audio.js
source share