I am trying to do TTS with Google Translate URL service.
Below is the code Javascript code.
function longSentenceSpeak(text)
{
var string = text.trim().split(" ").join("+");
var finalString = string.replace(";",",")
var url = "http://ift.tt/1E0UgLT"+finalString;
var audio = document.getElementById('audio');
var source = document.getElementById('source');
source.src=url;
audio.load(); //call this to just preload the audio without playing
audio.play(); //call this to play the song right away
}
Below is my HTML
TODO supply a title
<script src="scripts/TTS.js"></script>
<script>
function longText()
{
longSentenceSpeak("hello world ");
}
</script>
</head>
<body>
<audio id="audio">
<source id="source" src="" type="audio/wav" />
</audio>
<div><button onclick="longText()">Click me</button></div>
</body>
However this simply do not work, seems like HTML 5 audio is unable to handle the URL. When I run this code I get the below error.
Failed to load resource: the server responded with a status of 404 (Not Found) (12:49:15:455 | error, network)
at http://ift.tt/1J6J809
But I am sure the URL is correct, because you can try this
Below is the JS Fiddle Link
What have I done wrong here?
Aucun commentaire:
Enregistrer un commentaire