Skip to content

Commit

Permalink
Enable Download link
Browse files Browse the repository at this point in the history
  • Loading branch information
happyalu committed Feb 6, 2015
1 parent f4898e8 commit 82eab17
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gofliteweb.go
Expand Up @@ -63,6 +63,13 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
audio.setAttribute('src', '/wav?text=' + encodeURIComponent(text) + '&voice=' + encodeURIComponent(voice));
audio.play();
}
function download_tts() {
var text = document.getElementById('textarea').value;
var voice = document.getElementById('voice').options[document.getElementById('voice').selectedIndex].text;
var downloader = document.getElementById('downloader');
downloader.setAttribute('href', '/wav?text=' + encodeURIComponent(text) + '&voice=' + encodeURIComponent(voice));
downloader.click();
}
</script>
</head>
<body>
Expand All @@ -77,8 +84,10 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
</select> <br /> <br />
<textarea rows=3 cols=80 id="textarea" name="text">A whole joy was reaping, but they've gone south. Go fetch azure mike!</textarea>
<br /> <br />
<input type="submit" value="Speak!" onclick="play_tts();"> <br />
<input type="submit" value="Speak!" onclick="play_tts();"> &nbsp;&nbsp;&nbsp;
<input type="submit" value="Download!" onclick="download_tts();"> <br />
<audio id="player"></audio>
<a id="downloader" href="" download="flite.wav" target="_blank" style="display:none;"></a>
<br />
<br />
<br />
Expand Down

0 comments on commit 82eab17

Please sign in to comment.