Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added input area for text talking speed #19 #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@
display: block;
margin: 0 auto;
}
input#submit, input#download-button, input#copy-link-button {
input#submit, input#download-button, input#copy-link-button, input#playback-speed-input {
width: 248px;
text-align: center;
display: block;
margin: 1em auto;
}
input#playback-speed-input {
width: 240px ;
}
input#copy-link-button {
margin-bottom: 0;
}
Expand Down Expand Up @@ -121,13 +124,17 @@ <h1>phoneme synthesis</h1>

function copy_link_button() {
uipa = document.getElementById("ipa-input").value;
url = window.location.href.split('?')[0] + "?w=" + uipa;
playbackSpeed = document.getElementById("playback-speed-input").value;

url = window.location.href.split('?')[0] + "?w=" + uipa + "&s=" + playbackSpeed;

copyToClipboard(url);
}

function process() {
uipa = document.getElementById("ipa-input").value;

playbackSpeed = document.getElementById("playback-speed-input").value;

document.getElementById("download-button").disabled = true;

// nothing to process
Expand Down Expand Up @@ -261,8 +268,8 @@ <h1>phoneme synthesis</h1>
uipa = uipa.replace(mappings[i].src, mappings[i].dest);
//console.log(mappings[i].src + uipa);
}
console.log(uipa);
spoken = meSpeak.speak('[['+uipa+']]', { 'rawdata': 'mime' });
console.log(uipa);
spoken = meSpeak.speak('[['+uipa+']]', { 'rawdata': 'mime' , 'speed': playbackSpeed});
if (spoken == null) {
alert("An error occurred: speaking failed.");
}
Expand All @@ -278,6 +285,7 @@ <h1>phoneme synthesis</h1>
<p style="text-align: center;"><em>Convert <abbr title="International Phonetic Alphabet">IPA</abbr> phonetic notation to speech</em></p>
<form onsubmit="process(); return false;">
<input id="ipa-input" onchange="clear_download_button(); return false;" type="text" value="/mʊmˈbaɪ/" />
<input id="playback-speed-input" type="number" min="1" value="175">
<input id="submit" onclick="process(); return false;" type="button" value="pronounce" />
<input id="download-button" onclick="download(); return false;" type="button" disabled="disabled" value="download pronunciation" />
<input id="copy-link-button" onclick="copy_link_button(); return false;" type="button" value="copy share url" />
Expand Down Expand Up @@ -322,10 +330,16 @@ <h2>note</h2>
(function() {
var urlParams = new URLSearchParams(window.location.search);
if(urlParams.has('w')) {
var word = urlParams.get('w');
if(is_valid_input(word)) {
var word = urlParams.get('w');
if(is_valid_input(word)) {
document.getElementById("ipa-input").value = word;
}
}
}
if(urlParams.has('s')) {
var word = urlParams.get('s');
if(is_valid_input(word)) {
document.getElementById("playback-speed-input").value = word;
}
}
})();
</script>
Expand Down