Created
March 19, 2010 04:24
-
-
Save cheeaun/337230 to your computer and use it in GitHub Desktop.
Experimental page to test html5 <audio> tag with google translate tts technology.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<title>Say it to me!</title> | |
<link rel="stylesheet" href="http://cheeaun.github.com/cacss/ca.min.css"> | |
<style> | |
body{ | |
text-align: center; | |
} | |
input, button{ | |
font-size: 2em; | |
width: 70%; | |
margin: 0 0 1em; | |
padding: .2em; | |
} | |
</style> | |
<h1>Say it to me!</h1> | |
<form id="say-form"> | |
<input value="Awesome" id="say-text"> | |
<button id="say-button">Say!</button> | |
</form> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script> | |
var audioTagSupport = !!(document.createElement('audio').canPlayType); | |
$('#say-form').submit(function(){ | |
if (!audioTagSupport) return false; | |
var text = $.trim($('#say-text').val()); | |
if (text == '') return false; | |
var audio = document.createElement('audio'); | |
audio.setAttribute('src', 'http://translate.google.com/translate_tts?tl=en&q=' + encodeURIComponent(text)); | |
audio.load(); | |
audio.play(); | |
return false; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment