Skip to content

Instantly share code, notes, and snippets.

@omniosi
Created May 16, 2012 16:22
Show Gist options
  • Save omniosi/2711835 to your computer and use it in GitHub Desktop.
Save omniosi/2711835 to your computer and use it in GitHub Desktop.
target audio format and deliver correct format to HTML audio
var ispeech;
var message;
var canPlayOgg = !!(new Audio().canPlayType('audio/ogg; codecs="vorbis"'));
if(canPlayOgg == true){
ispeech = "http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&action=convert&voice=usenglishmale&format=ogg&text=";
} else{
ispeech = "http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&action=convert&voice=usenglishmale&text=";
}
$("#submit").click(function(){
message = $("#text").val();
$("audio").attr({
"autoplay": "autoplay",
"src": ( ispeech + message )
});
});
@omniosi
Copy link
Author

omniosi commented May 16, 2012

this is from a online app that spoke the text from a text field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment