json loading directly

master
Michael Murtaugh 6 years ago
parent 2612aab009
commit c0a8fe42b8

@ -1,52 +1,71 @@
{
"final": "Goodbye. Thank you for talking to me.",
"pre": [
"dont don't",
"cant can't",
"wont won't",
"recollect remember",
"dreamt dreamed",
"dreams dream",
"maybe perhaps",
"how what",
"when what",
"certainly yes",
"machine computer",
"computers computer",
"were was",
"you're you are",
"i'm i am",
"same alike"
],
"initial": "How do you do. Please tell me your problem.",
"keywords": [
{
"weight": 0,
"token": "xnone",
"rules": [
{
"decomp": "*",
"reasmb": [
"I'm not sure I understand you fully.",
"Please go on.",
"What does that suggest to you ?",
"Do you feel strongly about discussing such things ?"
]
],
"decomp": "*"
}
],
"token": "xnone"
]
},
{
"weight": 0,
"token": "sorry",
"rules": [
{
"decomp": "*",
"reasmb": [
"Please don't apologise.",
"Apologies are not necessary.",
"I've told you that apologies are not required."
]
],
"decomp": "*"
}
],
"token": "sorry"
]
},
{
"weight": 0,
"token": "apologise",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto sorry"
]
],
"decomp": "*"
}
],
"token": "apologise"
]
},
{
"weight": 5,
"token": "remember",
"rules": [
{
"decomp": "* i remember *",
"reasmb": [
"Do you often think of (2) ?",
"Does thinking of (2) bring anything else to mind ?",
@ -54,177 +73,177 @@
"Why do you recollect (2) just now ?",
"What in the present situation reminds you of (2) ?",
"What is the connection between me and (2) ?"
]
],
"decomp": "* i remember *"
},
{
"decomp": "* do you remember *",
"reasmb": [
"Did you think I would forget (2) ?",
"Why do you think I should recall (2) now ?",
"What about (2) ?",
"goto what",
"You mentioned (2) ?"
]
],
"decomp": "* do you remember *"
}
],
"token": "remember"
]
},
{
"weight": 3,
"token": "if",
"rules": [
{
"decomp": "* if *",
"reasmb": [
"Do you think its likely that (2) ?",
"Do you wish that (2) ?",
"What do you know about (2) ?",
"Really, if (2) ?"
]
],
"decomp": "* if *"
}
],
"token": "if"
]
},
{
"weight": 4,
"token": "dreamed",
"rules": [
{
"decomp": "* i dreamed *",
"reasmb": [
"Really, (2) ?",
"Have you ever fantasized (2) while you were awake ?",
"Have you ever dreamed (2) before ?",
"goto dream"
]
],
"decomp": "* i dreamed *"
}
],
"token": "dreamed"
]
},
{
"weight": 3,
"token": "dream",
"rules": [
{
"decomp": "*",
"reasmb": [
"What does that dream suggest to you ?",
"Do you dream often ?",
"What persons appear in your dreams ?",
"Do you believe that dreams have something to do with your problems ?"
]
],
"decomp": "*"
}
],
"token": "dream"
]
},
{
"weight": 0,
"token": "perhaps",
"rules": [
{
"decomp": "*",
"reasmb": [
"You don't seem quite certain.",
"Why the uncertain tone ?",
"Can't you be more positive ?",
"You aren't sure ?",
"Don't you know ?"
]
],
"decomp": "*"
}
],
"token": "perhaps"
]
},
{
"weight": 15,
"token": "name",
"rules": [
{
"decomp": "*",
"reasmb": [
"I am not interested in names.",
"I've told you before, I don't care about names -- please continue."
]
],
"decomp": "*"
}
],
"token": "name"
]
},
{
"weight": 0,
"token": "deutsch",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto xforeign",
"I told you before, I don't understand German."
]
],
"decomp": "*"
}
],
"token": "deutsch"
]
},
{
"weight": 0,
"token": "francais",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto xforeign",
"I told you before, I don't understand French."
]
],
"decomp": "*"
}
],
"token": "francais"
]
},
{
"weight": 0,
"token": "italiano",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto xforeign",
"I told you before, I don't understand Italian."
]
],
"decomp": "*"
}
],
"token": "italiano"
]
},
{
"weight": 0,
"token": "espanol",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto xforeign",
"I told you before, I don't understand Spanish."
]
],
"decomp": "*"
}
],
"token": "espanol"
]
},
{
"weight": 0,
"token": "xforeign",
"rules": [
{
"decomp": "*",
"reasmb": [
"I speak only English."
]
],
"decomp": "*"
}
],
"token": "xforeign"
]
},
{
"weight": 0,
"token": "hello",
"rules": [
{
"decomp": "*",
"reasmb": [
"How do you do. Please state your problem.",
"Hi. What seems to be your problem ?"
]
],
"decomp": "*"
}
],
"token": "hello"
]
},
{
"weight": 50,
"token": "computer",
"rules": [
{
"decomp": "*",
"reasmb": [
"Do computers worry you ?",
"Why do you mention computers ?",
@ -232,79 +251,79 @@
"Don't you think computers can help people ?",
"What about machines worrys you ?",
"What do you think about machines ?"
]
],
"decomp": "*"
}
],
"token": "computer"
]
},
{
"weight": 0,
"token": "am",
"rules": [
{
"decomp": "* am i *",
"reasmb": [
"Do you believe you are (2) ?",
"Would you want to be (2) ?",
"Do you wish I would tell you you are (2) ?",
"What would it mean if you were (2) ?",
"goto what"
]
],
"decomp": "* am i *"
},
{
"decomp": "*",
"reasmb": [
"Why do you say 'am' ?",
"I don't understand that."
]
],
"decomp": "*"
}
],
"token": "am"
]
},
{
"weight": 0,
"token": "are",
"rules": [
{
"decomp": "* are you *",
"reasmb": [
"Why are you interested in whether I am (2) or not ?",
"Would you prefer if I weren't (2) ?",
"Perhaps I am (2) in your fantasies.",
"Do you sometimes think I am (2) ?",
"goto what"
]
],
"decomp": "* are you *"
},
{
"decomp": "* are *",
"reasmb": [
"Did you think they might not be (2) ?",
"Would you like it if they were not (2) ?",
"What if they were not (2) ?",
"Possibly they are (2)."
]
],
"decomp": "* are *"
}
],
"token": "are"
]
},
{
"weight": 0,
"token": "your",
"rules": [
{
"decomp": "* your *",
"reasmb": [
"Why are you concerned over my (2) ?",
"What about your own (2) ?",
"Are you worried about someone else's (2) ?",
"Really, my (2) ?"
]
],
"decomp": "* your *"
}
],
"token": "your"
]
},
{
"weight": 2,
"token": "was",
"rules": [
{
"decomp": "* was i *",
"reasmb": [
"What if you were (2) ?",
"Do you think you were (2) ?",
@ -312,34 +331,34 @@
"What would it mean if you were (2) ?",
"What does (2) suggest to you ?",
"goto what"
]
],
"decomp": "* was i *"
},
{
"decomp": "* i was *",
"reasmb": [
"Were you really ?",
"Why do you tell me you were (2) now ?",
"Perhaps I already know you were (2)."
]
],
"decomp": "* i was *"
},
{
"decomp": "* was you *",
"reasmb": [
"Would you like to believe I was (2) ?",
"What suggests that I was (2) ?",
"What do you think ?",
"Perhaps I was (2).",
"What if I had been (2) ?"
]
],
"decomp": "* was you *"
}
],
"token": "was"
]
},
{
"weight": 0,
"token": "i",
"rules": [
{
"decomp": "* i @desire *",
"reasmb": [
"What would it mean to you if you got (3) ?",
"Why do you want (3) ?",
@ -347,123 +366,123 @@
"What if you never got (3) ?",
"What would getting (3) mean to you ?",
"What does wanting (3) have to do with this discussion ?"
]
],
"decomp": "* i @desire *"
},
{
"decomp": "* i am* @sad *",
"reasmb": [
"I am sorry to hear that you are (3).",
"Do you think that coming here will help you not to be (3) ?",
"I'm sure it's not pleasant to be (3).",
"Can you explain what made you (3) ?"
]
],
"decomp": "* i am* @sad *"
},
{
"decomp": "* i am* @happy *",
"reasmb": [
"How have I helped you to be (3) ?",
"Has your treatment made you (3) ?",
"What makes you (3) just now ?",
"Can you explan why you are suddenly (3) ?"
]
],
"decomp": "* i am* @happy *"
},
{
"decomp": "* i was *",
"reasmb": [
"goto was"
]
],
"decomp": "* i was *"
},
{
"decomp": "* i @belief * i *",
"reasmb": [
"Do you really think so ?",
"But you are not sure you (3).",
"Do you really doubt you (3) ?"
]
],
"decomp": "* i @belief * i *"
},
{
"decomp": "* i* @belief *you *",
"reasmb": [
"goto you"
]
],
"decomp": "* i* @belief *you *"
},
{
"decomp": "* i am *",
"reasmb": [
"Is it because you are (2) that you came to me ?",
"How long have you been (2) ?",
"Do you believe it is normal to be (2) ?",
"Do you enjoy being (2) ?"
]
],
"decomp": "* i am *"
},
{
"decomp": "* i @cannot *",
"reasmb": [
"How do you think that you can't (3) ?",
"Have you tried ?",
"Perhaps you could (3) now.",
"Do you really want to be able to (3) ?"
]
],
"decomp": "* i @cannot *"
},
{
"decomp": "* i don't *",
"reasmb": [
"Don't you really (2) ?",
"Why don't you (2) ?",
"Do you wish to be able to (2) ?",
"Does that trouble you ?"
]
],
"decomp": "* i don't *"
},
{
"decomp": "* do i feel *",
"reasmb": [
"Tell me more about such feelings.",
"Do you often feel (2) ?",
"Do you enjoy feeling (2) ?",
"Of what does feeling (2) remind you ?"
]
],
"decomp": "* do i feel *"
},
{
"decomp": "* i * you *",
"reasmb": [
"Perhaps in your fantasies we (2) each other.",
"Do you wish to (2) me ?",
"You seem to need to (2) me.",
"Do you (2) anyone else ?"
]
],
"decomp": "* i * you *"
},
{
"decomp": "*",
"reasmb": [
"You say (1) ?",
"Can you elaborate on that ?",
"Do you say (1) for some special reason ?",
"That's quite interesting."
]
],
"decomp": "*"
}
],
"token": "i"
]
},
{
"weight": 0,
"token": "you",
"rules": [
{
"decomp": "* you remind me of *",
"reasmb": [
"goto alike"
]
],
"decomp": "* you remind me of *"
},
{
"decomp": "* you are *",
"reasmb": [
"What makes you think I am (2) ?",
"Does it please you to believe I am (2) ?",
"Do you sometimes wish you were (2) ?",
"Perhaps you would like to be (2)."
]
],
"decomp": "* you are *"
},
{
"decomp": "* you* me *",
"reasmb": [
"Why do you think I (2) you ?",
"You like to think I (2) you -- don't you ?",
@ -472,113 +491,113 @@
"Do you wish to believe I (2) you ?",
"Suppose I did (2) you -- what would that mean ?",
"Does someone else believe I (2) you ?"
]
],
"decomp": "* you* me *"
},
{
"decomp": "* you *",
"reasmb": [
"We were discussing you -- not me.",
"Oh, I (2) ?",
"You're not really talking about me -- are you ?",
"What are your feelings now ?"
]
],
"decomp": "* you *"
}
],
"token": "you"
]
},
{
"weight": 0,
"token": "yes",
"rules": [
{
"decomp": "*",
"reasmb": [
"You seem to be quite positive.",
"You are sure.",
"I see.",
"I understand."
]
],
"decomp": "*"
}
],
"token": "yes"
]
},
{
"weight": 0,
"token": "no",
"rules": [
{
"decomp": "*",
"reasmb": [
"Are you saying no just to be negative?",
"You are being a bit negative.",
"Why not ?",
"Why 'no' ?"
]
],
"decomp": "*"
}
],
"token": "no"
]
},
{
"weight": 2,
"token": "my",
"rules": [
{
"decomp": "* my *",
"save": true,
"reasmb": [
"Does that have anything to do with the fact that your (2) ?",
"Lets discuss further why your (2).",
"Earlier you said your (2).",
"But your (2)."
]
],
"decomp": "* my *"
},
{
"decomp": "* my* @family *",
"reasmb": [
"Tell me more about your family.",
"Who else in your family (4) ?",
"Your (3) ?",
"What else comes to mind when you think of your (3) ?"
]
],
"decomp": "* my* @family *"
},
{
"decomp": "* my *",
"reasmb": [
"Your (2) ?",
"Why do you say your (2) ?",
"Does that suggest anything else which belongs to you ?",
"Is it important that your (2) ?"
]
],
"decomp": "* my *"
}
],
"token": "my"
]
},
{
"weight": 0,
"token": "can",
"rules": [
{
"decomp": "* can you *",
"reasmb": [
"You believe I can (2) don't you ?",
"goto what",
"You want me to be able to (2).",
"Perhaps you would like to be able to (2) yourself."
]
],
"decomp": "* can you *"
},
{
"decomp": "* can i *",
"reasmb": [
"Whether or not you can (2) depends on you more than me.",
"Do you want to be able to (2) ?",
"Perhaps you don't want to (2).",
"goto what"
]
],
"decomp": "* can i *"
}
],
"token": "can"
]
},
{
"weight": 0,
"token": "what",
"rules": [
{
"decomp": "*",
"reasmb": [
"Why do you ask ?",
"Does that question interest you ?",
@ -589,63 +608,63 @@
"What comes to mind when you ask that ?",
"Have you asked such questions before ?",
"Have you asked anyone else ?"
]
],
"decomp": "*"
}
],
"token": "what"
]
},
{
"weight": 0,
"token": "because",
"rules": [
{
"decomp": "*",
"reasmb": [
"Is that the real reason ?",
"Don't any other reasons come to mind ?",
"Does that reason seem to explain anything else ?",
"What other reasons might there be ?"
]
],
"decomp": "*"
}
],
"token": "because"
]
},
{
"weight": 0,
"token": "why",
"rules": [
{
"decomp": "* why don't you *",
"reasmb": [
"Do you believe I don't (2) ?",
"Perhaps I will (2) in good time.",
"Should you (2) yourself ?",
"You want me to (2) ?",
"goto what"
]
],
"decomp": "* why don't you *"
},
{
"decomp": "* why can't i *",
"reasmb": [
"Do you think you should be able to (2) ?",
"Do you want to be able to (2) ?",
"Do you believe this will help you to (2) ?",
"Have you any idea why you can't (2) ?",
"goto what"
]
],
"decomp": "* why can't i *"
},
{
"decomp": "*",
"reasmb": [
"goto what"
]
],
"decomp": "*"
}
],
"token": "why"
]
},
{
"weight": 2,
"token": "everyone",
"rules": [
{
"decomp": "* @everyone *",
"reasmb": [
"Realy, (2) ?",
"Surely not (2).",
@ -656,67 +675,67 @@
"Someone special perhaps ?",
"You have a particular person in mind, don't you ?",
"Who do you think you're talking about ?"
]
],
"decomp": "* @everyone *"
}
],
"token": "everyone"
]
},
{
"weight": 2,
"token": "everybody",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto everyone"
]
],
"decomp": "*"
}
],
"token": "everybody"
]
},
{
"weight": 2,
"token": "nobody",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto everyone"
]
],
"decomp": "*"
}
],
"token": "nobody"
]
},
{
"weight": 2,
"token": "noone",
"rules": [
{
"decomp": "*",
"reasmb": [
"goto everyone"
]
],
"decomp": "*"
}
],
"token": "noone"
]
},
{
"weight": 1,
"token": "always",
"rules": [
{
"decomp": "*",
"reasmb": [
"Can you think of a specific example ?",
"When ?",
"What incident are you thinking of ?",
"Really, always ?"
]
],
"decomp": "*"
}
],
"token": "always"
]
},
{
"weight": 10,
"token": "alike",
"rules": [
{
"decomp": "*",
"reasmb": [
"In what way ?",
"What resemblence do you see ?",
@ -726,25 +745,24 @@
"What is the connection, do you suppose ?",
"Could here really be some connection ?",
"How ?"
]
],
"decomp": "*"
}
],
"token": "alike"
]
},
{
"weight": 10,
"token": "like",
"rules": [
{
"decomp": "* @be *like *",
"reasmb": [
"goto alike"
]
],
"decomp": "* @be *like *"
}
],
"token": "like"
]
}
],
"final": "Goodbye. Thank you for talking to me.",
"post": [
"am are",
"your my",
@ -766,23 +784,5 @@
"everyone everybody nobody noone",
"be am is are was"
],
"pre": [
"dont don't",
"cant can't",
"wont won't",
"recollect remember",
"dreamt dreamed",
"dreams dream",
"maybe perhaps",
"how what",
"when what",
"certainly yes",
"machine computer",
"computers computer",
"were was",
"you're you are",
"i'm i am",
"same alike"
],
"quit": []
}

@ -51,7 +51,20 @@
</div>
<script src="eliza.js"></script>
<script>
function eliza (rules) {
function get_json (url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
callback(data);
} else { callback("server error"); }
};
request.onerror = function() { callback("connection error"); };
request.send();
}
get_json("doctor.json", function (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
@ -78,8 +91,8 @@ function eliza (rules) {
}
});
say(rules.initial);
}
});
</script>
<script src="doctor.js"></script>
</body>
</html>

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
#wrapper {
display: flex;
flex-direction: column;
position: absolute;
left: 5%; top: 5%; right: 5%; bottom: 5%;
}
#textinput {
width: 100%;
border: none;
background: none;
}
#input {
padding: 2%;
flex: 0 1 auto;
background: aqua;
}
#display {
flex: 1 1 auto;
background: pink;
padding: 2%;
overflow: auto;
}
#display div.msg {
padding-bottom: 0.5em;
}
#display div.human {
color: black;
}
#display div.bot {
color: black;
text-transform: uppercase;
}
#display div.debug {
color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="display">
</div>
<div id="input">
<input type="text" id="textinput" autofocus />
</div>
</div>
<script src="eliza.js"></script>
<script>
function eliza (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
function log (msg, kls) {
var d = document.createElement("div");
d.setAttribute("class", "msg " + kls);
d.innerHTML = msg;
display.appendChild(d);
}
function say (msg) {
log(msg, "bot");
display.scrollTop = display.scrollTopMax;
}
input.addEventListener("keypress", function (event) {
if (event.keyCode == 13) {
var text = input.value;
log(text, "user");
say(bot(text), "bot");
input.value = "";
input.focus();
}
});
say(rules.initial);
}
</script>
<script src="doctor.js"></script>
</body>
</html>

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
#wrapper {
display: flex;
flex-direction: column;
position: absolute;
left: 5%; top: 5%; right: 5%; bottom: 5%;
}
#textinput {
width: 100%;
border: none;
background: none;
}
#input {
padding: 2%;
flex: 0 1 auto;
background: aqua;
}
#display {
flex: 1 1 auto;
background: pink;
padding: 2%;
overflow: auto;
}
#display div.msg {
padding-bottom: 0.5em;
}
#display div.human {
color: black;
}
#display div.bot {
color: black;
text-transform: uppercase;
}
#display div.debug {
color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="display">
</div>
<div id="input">
<input type="text" id="textinput" autofocus />
</div>
</div>
<script src="eliza.js"></script>
<script>
function get_json (url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
callback(data);
} else { callback("server error"); }
};
request.onerror = function() { callback("connection error"); };
request.send();
}
get_json("doctor.json", function (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
function log (msg, kls) {
var d = document.createElement("div");
d.setAttribute("class", "msg " + kls);
d.innerHTML = msg;
display.appendChild(d);
}
function say (msg) {
responsiveVoice.speak(msg)
log(msg, "bot");
// https://responsivevoice.org/api/
display.scrollTop = display.scrollTopMax;
// responsiveVoice.speak("hello world", "UK English Male", {onstart: StartCallback, onend: EndCallback});
}
var voicelist = responsiveVoice.getVoices();
console.log("voicelist", voicelist);
responsiveVoice.setDefaultVoice("US English Female");
input.addEventListener("keypress", function (event) {
if (event.keyCode == 13) {
var text = input.value;
log(text, "user");
say(bot(text), "bot");
input.value = "";
input.focus();
}
});
say(rules.initial);
});
</script>
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
</body>
</html>

@ -1,4 +1,7 @@
%.json: %.txt
python3 eliza_script_to_json.py < $< > $@
%.js: %.json
python3 jsonp.py --callback "eliza" < $< > $@
python3 jsonp.py --callback "eliza" < $< > $@
doctor.html: doctor.json
python3 json_to_print.py $< rules.template.html > $@

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>Speech synthesiser</title>
<link rel="stylesheet" href="style.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<h1>Speech synthesiser</h1>
<p>Enter some text in the input below and press return to hear it. change voices using the dropdown menu.</p>
<form>
<input type="text" class="txt">
<div>
<label for="rate">Rate</label><input type="range" min="0.5" max="2" value="1" step="0.1" id="rate">
<div class="rate-value">1</div>
<div class="clearfix"></div>
</div>
<div>
<label for="pitch">Pitch</label><input type="range" min="0" max="2" value="1" step="0.1" id="pitch">
<div class="pitch-value">1</div>
<div class="clearfix"></div>
</div>
<select>
</select>
</form>
<script src="speech.js"></script>
</body>
</html>

@ -0,0 +1,67 @@
var synth = window.speechSynthesis;
var inputForm = document.querySelector('form');
var inputTxt = document.querySelector('.txt');
var voiceSelect = document.querySelector('select');
var pitch = document.querySelector('#pitch');
var pitchValue = document.querySelector('.pitch-value');
var rate = document.querySelector('#rate');
var rateValue = document.querySelector('.rate-value');
var voices = [];
function populateVoiceList() {
voices = synth.getVoices();
var selectedIndex = voiceSelect.selectedIndex < 0 ? 0 : voiceSelect.selectedIndex;
voiceSelect.innerHTML = '';
for(i = 0; i < voices.length ; i++) {
var option = document.createElement('option');
option.textContent = voices[i].name + ' (' + voices[i].lang + ')';
if(voices[i].default) {
option.textContent += ' -- DEFAULT';
}
option.setAttribute('data-lang', voices[i].lang);
option.setAttribute('data-name', voices[i].name);
voiceSelect.appendChild(option);
}
voiceSelect.selectedIndex = selectedIndex;
}
populateVoiceList();
if (speechSynthesis.onvoiceschanged !== undefined) {
speechSynthesis.onvoiceschanged = populateVoiceList;
}
inputForm.onsubmit = function(event) {
event.preventDefault();
var utterThis = new SpeechSynthesisUtterance(inputTxt.value);
var selectedOption = voiceSelect.selectedOptions[0].getAttribute('data-name');
for(i = 0; i < voices.length ; i++) {
if(voices[i].name === selectedOption) {
utterThis.voice = voices[i];
}
}
utterThis.pitch = pitch.value;
utterThis.rate = rate.value;
synth.speak(utterThis);
utterThis.onpause = function(event) {
var char = event.utterance.text.charAt(event.charIndex);
console.log('Speech paused at character ' + event.charIndex + ' of "' +
event.utterance.text + '", which is "' + char + '".');
}
inputTxt.blur();
}
pitch.onchange = function() {
pitchValue.textContent = pitch.value;
}
rate.onchange = function() {
rateValue.textContent = rate.value;
}
Loading…
Cancel
Save