<html lang="en"> <center>
Are you unsure how to pronounce a word?Use your browser's speech synthesis system to pronounce any word or phrase you type into the input box below.
<input id="mytext" style="font-size: 18pt; size: 50;" type="text" />
<button id="activate">Pronounce it</button></center>
</html>
<script>
function sayIt(query, language) {
var q = new SpeechSynthesisUtterance(query);
q.lang = language;
q.rate = 0.8;
speechSynthesis.speak(q);
}
function attach(elementId, event, functionName) {
var element = document.getElementById(elementId);
if (element.addEventListener) {
element.addEventListener(event, functionName, false);
} else if (element.attachEvent) {
element.attachEvent('on' + event, functionName);
} else {
element['on' + event] = functionName;
}
}
function interpret() {
sayIt(document.getElementById('mytext').value, 'en-US');
}
attach('activate', 'click', interpret);
</script>
<center>
<span style="font-size: xx-small;">Adapted code based on Jason Mayes' example here: <a href="http://codepen.io/anon/pen/xGXZaW">http://codepen.io/anon/pen/xGXZaW</a>
Click the HTML button of your blog, and copy/paste the code found <a href="http://chatbotmaker.com/Speech/tts_code.txt">here</a>.
I checked this blog post for common grammar, punctuation and spelling errors using a <a href="http://virtualwritingtutor.com/" target="_blank">free online ESL grammar checker</a>.</span></center>
Comments
Post a Comment