ggerganov commited on
Commit
b38c009
·
unverified ·
1 Parent(s): 28726dd

talk.wasm : polishing + adding many AI personalities

Browse files
bindings/javascript/whisper.js CHANGED
The diff for this file is too large to render. See raw diff
 
examples/talk.wasm/README.md CHANGED
@@ -31,6 +31,15 @@ In order to run this demo efficiently, you need to have the following:
31
  - Speak phrases that are no longer than 10 seconds - this is the audio context of the AI
32
  - The web-page uses about 1.4GB of RAM
33
 
 
 
 
 
 
 
 
 
 
34
  ## Feedback
35
 
36
  If you have any comments or ideas for improvement, please drop a comment in the following discussion:
 
31
  - Speak phrases that are no longer than 10 seconds - this is the audio context of the AI
32
  - The web-page uses about 1.4GB of RAM
33
 
34
+ Notice that this demo is using the smallest GPT-2 model, so the generated text responses are not always very good.
35
+ Also, the prompting strategy can likely be improved to achieve better results.
36
+
37
+ The demo is quite computationally heavy - it's not usual to run these transformer models in a browser. Typically, they
38
+ run on powerful GPU hardware. So for better experience, you do need to have a powerful computer.
39
+
40
+ Probably in the near future, mobile browsers will start to support the WASM SIMD capabilities and this will allow
41
+ to run the demo on your phone or tablet. But for now it seems to be not supported (at least on iPhone).
42
+
43
  ## Feedback
44
 
45
  If you have any comments or ideas for improvement, please drop a comment in the following discussion:
examples/talk.wasm/emscripten.cpp CHANGED
@@ -988,7 +988,7 @@ std::atomic<bool> g_running(false);
988
 
989
  bool g_force_speak = false;
990
  std::string g_text_to_speak = "";
991
- std::string g_status = "idle";
992
  std::string g_status_forced = "";
993
 
994
  std::string gpt2_gen_text(const std::string & prompt) {
@@ -997,7 +997,7 @@ std::string gpt2_gen_text(const std::string & prompt) {
997
  std::vector<float> embd_w;
998
 
999
  // tokenize the prompt
1000
- std::vector<gpt_vocab::id> embd_inp = ::gpt_tokenize(g_gpt2.vocab, g_gpt2.prompt_base + prompt);
1001
 
1002
  g_gpt2.n_predict = std::min(g_gpt2.n_predict, g_gpt2.model.hparams.n_ctx - (int) embd_inp.size());
1003
 
@@ -1088,6 +1088,8 @@ void talk_main(size_t index) {
1088
  printf("gpt-2: model loaded in %d ms\n", (int) (t_load_us/1000));
1089
  }
1090
 
 
 
1091
  std::vector<float> pcmf32;
1092
 
1093
  auto & ctx = g_contexts[index];
@@ -1214,9 +1216,15 @@ void talk_main(size_t index) {
1214
  printf("whisper: number of tokens: %d, '%s'\n", (int) tokens.size(), text_heard.c_str());
1215
 
1216
  std::string text_to_speak;
 
 
 
 
 
 
1217
 
1218
  if (tokens.size() > 0) {
1219
- text_to_speak = gpt2_gen_text(text_heard + "\n");
1220
  text_to_speak = std::regex_replace(text_to_speak, std::regex("[^a-zA-Z0-9\\.,\\?!\\s\\:\\'\\-]"), "");
1221
  text_to_speak = text_to_speak.substr(0, text_to_speak.find_first_of("\n"));
1222
 
@@ -1224,36 +1232,36 @@ void talk_main(size_t index) {
1224
 
1225
  // remove first 2 lines of base prompt
1226
  {
1227
- const size_t pos = g_gpt2.prompt_base.find_first_of("\n");
1228
  if (pos != std::string::npos) {
1229
- g_gpt2.prompt_base = g_gpt2.prompt_base.substr(pos + 1);
1230
  }
1231
  }
1232
  {
1233
- const size_t pos = g_gpt2.prompt_base.find_first_of("\n");
1234
  if (pos != std::string::npos) {
1235
- g_gpt2.prompt_base = g_gpt2.prompt_base.substr(pos + 1);
1236
  }
1237
  }
1238
- g_gpt2.prompt_base += text_heard + "\n" + text_to_speak + "\n";
1239
  } else {
1240
- text_to_speak = gpt2_gen_text("");
1241
  text_to_speak = std::regex_replace(text_to_speak, std::regex("[^a-zA-Z0-9\\.,\\?!\\s\\:\\'\\-]"), "");
1242
  text_to_speak = text_to_speak.substr(0, text_to_speak.find_first_of("\n"));
1243
 
1244
  std::lock_guard<std::mutex> lock(g_mutex);
1245
 
1246
- const size_t pos = g_gpt2.prompt_base.find_first_of("\n");
1247
  if (pos != std::string::npos) {
1248
- g_gpt2.prompt_base = g_gpt2.prompt_base.substr(pos + 1);
1249
  }
1250
- g_gpt2.prompt_base += text_to_speak + "\n";
1251
  }
1252
 
1253
  printf("gpt-2: %s\n", text_to_speak.c_str());
1254
 
1255
  //printf("========================\n");
1256
- //printf("gpt-2: prompt_base:\n'%s'\n", g_gpt2.prompt_base.c_str());
1257
  //printf("========================\n");
1258
 
1259
  {
@@ -1261,6 +1269,7 @@ void talk_main(size_t index) {
1261
  t_last = std::chrono::high_resolution_clock::now();
1262
  g_text_to_speak = text_to_speak;
1263
  g_pcmf32.clear();
 
1264
  }
1265
 
1266
  talk_set_status("speaking ...");
@@ -1376,4 +1385,11 @@ EMSCRIPTEN_BINDINGS(talk) {
1376
  g_status_forced = status;
1377
  }
1378
  }));
 
 
 
 
 
 
 
1379
  }
 
988
 
989
  bool g_force_speak = false;
990
  std::string g_text_to_speak = "";
991
+ std::string g_status = "";
992
  std::string g_status_forced = "";
993
 
994
  std::string gpt2_gen_text(const std::string & prompt) {
 
997
  std::vector<float> embd_w;
998
 
999
  // tokenize the prompt
1000
+ std::vector<gpt_vocab::id> embd_inp = ::gpt_tokenize(g_gpt2.vocab, prompt);
1001
 
1002
  g_gpt2.n_predict = std::min(g_gpt2.n_predict, g_gpt2.model.hparams.n_ctx - (int) embd_inp.size());
1003
 
 
1088
  printf("gpt-2: model loaded in %d ms\n", (int) (t_load_us/1000));
1089
  }
1090
 
1091
+ printf("talk: using %d threads\n", N_THREAD);
1092
+
1093
  std::vector<float> pcmf32;
1094
 
1095
  auto & ctx = g_contexts[index];
 
1216
  printf("whisper: number of tokens: %d, '%s'\n", (int) tokens.size(), text_heard.c_str());
1217
 
1218
  std::string text_to_speak;
1219
+ std::string prompt_base;
1220
+
1221
+ {
1222
+ std::lock_guard<std::mutex> lock(g_mutex);
1223
+ prompt_base = g_gpt2.prompt_base;
1224
+ }
1225
 
1226
  if (tokens.size() > 0) {
1227
+ text_to_speak = gpt2_gen_text(prompt_base + text_heard + "\n");
1228
  text_to_speak = std::regex_replace(text_to_speak, std::regex("[^a-zA-Z0-9\\.,\\?!\\s\\:\\'\\-]"), "");
1229
  text_to_speak = text_to_speak.substr(0, text_to_speak.find_first_of("\n"));
1230
 
 
1232
 
1233
  // remove first 2 lines of base prompt
1234
  {
1235
+ const size_t pos = prompt_base.find_first_of("\n");
1236
  if (pos != std::string::npos) {
1237
+ prompt_base = prompt_base.substr(pos + 1);
1238
  }
1239
  }
1240
  {
1241
+ const size_t pos = prompt_base.find_first_of("\n");
1242
  if (pos != std::string::npos) {
1243
+ prompt_base = prompt_base.substr(pos + 1);
1244
  }
1245
  }
1246
+ prompt_base += text_heard + "\n" + text_to_speak + "\n";
1247
  } else {
1248
+ text_to_speak = gpt2_gen_text(prompt_base);
1249
  text_to_speak = std::regex_replace(text_to_speak, std::regex("[^a-zA-Z0-9\\.,\\?!\\s\\:\\'\\-]"), "");
1250
  text_to_speak = text_to_speak.substr(0, text_to_speak.find_first_of("\n"));
1251
 
1252
  std::lock_guard<std::mutex> lock(g_mutex);
1253
 
1254
+ const size_t pos = prompt_base.find_first_of("\n");
1255
  if (pos != std::string::npos) {
1256
+ prompt_base = prompt_base.substr(pos + 1);
1257
  }
1258
+ prompt_base += text_to_speak + "\n";
1259
  }
1260
 
1261
  printf("gpt-2: %s\n", text_to_speak.c_str());
1262
 
1263
  //printf("========================\n");
1264
+ //printf("gpt-2: prompt_base:\n'%s'\n", prompt_base.c_str());
1265
  //printf("========================\n");
1266
 
1267
  {
 
1269
  t_last = std::chrono::high_resolution_clock::now();
1270
  g_text_to_speak = text_to_speak;
1271
  g_pcmf32.clear();
1272
+ g_gpt2.prompt_base = prompt_base;
1273
  }
1274
 
1275
  talk_set_status("speaking ...");
 
1385
  g_status_forced = status;
1386
  }
1387
  }));
1388
+
1389
+ emscripten::function("set_prompt", emscripten::optional_override([](const std::string & prompt) {
1390
+ {
1391
+ std::lock_guard<std::mutex> lock(g_mutex);
1392
+ g_gpt2.prompt_base = prompt;
1393
+ }
1394
+ }));
1395
  }
examples/talk.wasm/index-tmpl.html CHANGED
@@ -31,12 +31,12 @@
31
 
32
  <br><br>
33
 
34
- On this page you can talk with an AI entity. It uses:
35
 
36
  <ul>
37
- <li><a href="https://github.com/ggerganov/whisper.cpp">OpenAI's Whisper</a> model to listen to you as you speak in the microphone</li>
38
- <li><a href="https://github.com/ggerganov/ggml/tree/master/examples/gpt-2">OpenAI's GPT-2</a> model to generate a text response</li>
39
- <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">Web Speech API</a> to speak the response to you through the speakers</li>
40
  </ul>
41
 
42
  All of this runs <b>locally in your browser</b> using WebAssembly.<br>
@@ -77,20 +77,43 @@
77
  <br>
78
 
79
  <div id="input">
80
- <button id="start" onclick="onStart()">Start</button>
81
- <button id="stop" onclick="onStop()" disabled>Stop</button>
82
- <select id="voice" onchange="onVoiceChange()">
83
  <option value="0">Default</option>
84
  </select>
85
- <button id="speak" onclick="onSpeak('Hello')">Say hello</button>
86
- <button id="speak" onclick="onSpeakRandom()">Say something</button>
87
- <button id="speak" onclick="clearCache()">Clear Cache</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  </div>
89
 
90
  <br>
91
 
92
  <div id="state">
93
- Status: <b><span id="state-status">idle</span></b>
94
 
95
  <pre id="state-context">[The text context will be displayed here]</pre>
96
  </div>
@@ -110,12 +133,10 @@
110
 
111
  <ul>
112
  <li>To use a modern web browser (e.g. Chrome, Firefox)</li>
113
- <li>To use a fast desktop or laptop computer (e.g. not a mobile phone)</li>
114
  <li>Your browser supports WASM <a href="https://webassembly.org/roadmap/">Fixed-width SIMD</a></li>
115
  </ul>
116
 
117
- <br><br>
118
-
119
  <div class="cell-version">
120
  <span>
121
  |
@@ -183,25 +204,30 @@
183
  var voices = synth.getVoices();
184
  var el = document.getElementById('voice');
185
 
186
- var n = 0;
187
- voices.forEach(function(voice, i) {
188
- if (!voice.lang.startsWith('en')) return;
189
- var option = document.createElement('option');
190
- option.value = i;
191
- option.innerHTML = voice.name + ' (' + voice.lang + ')';
192
- el.appendChild(option);
193
- n++;
194
- });
 
 
 
 
195
 
196
- // select random voice
197
- if (n > 0) {
198
- for (var k = 0; k < 10; k++) {
199
- var i = Math.floor(Math.random() * n);
200
- el.selectedIndex = i;
201
- voice = voices[document.getElementById('voice').options[i].value];
202
 
203
- // give preference to Google voices
204
- if (voice.name.startsWith('Google')) break;
 
205
  }
206
  }
207
  }
@@ -236,6 +262,12 @@
236
  } else if (fname == 'gpt-2.bin') {
237
  document.getElementById('model-gpt-2').innerHTML = 'GPT-2 model: loaded "' + model_gpt_2 + '"!';
238
  }
 
 
 
 
 
 
239
  }
240
 
241
  let dbVersion = 1
@@ -344,9 +376,10 @@
344
 
345
  // alert and ask the user to confirm
346
  if (!confirm('You are about to download ' + size_mb + ' MB of data.\nThe model data will be cached in the browser for future use.\n\nPress OK to continue.')) {
347
- document.getElementById('fetch-whisper-tiny-en').style.display = 'inline-block';
348
- document.getElementById('fetch-whisper-base-en').style.display = 'inline-block';
349
- document.getElementById('fetch-gpt-2-small').style.display = 'inline-block';
 
350
  return;
351
  }
352
 
@@ -465,6 +498,7 @@
465
 
466
  document.getElementById('start').disabled = true;
467
  document.getElementById('stop').disabled = false;
 
468
 
469
  doRecording = true;
470
  startTime = Date.now();
@@ -539,6 +573,7 @@
539
 
540
  document.getElementById('start').disabled = false;
541
  document.getElementById('stop').disabled = true;
 
542
 
543
  mediaRecorder = null;
544
  }
@@ -644,6 +679,281 @@
644
  voice = synth.getVoices()[document.getElementById('voice').value];
645
  }
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  </script>
648
  <script type="text/javascript" src="talk.js"></script>
649
  </body>
 
31
 
32
  <br><br>
33
 
34
+ Talk with an Artificial Intelligence in your browser. This demo uses:
35
 
36
  <ul>
37
+ <li><a href="https://github.com/ggerganov/whisper.cpp">OpenAI's Whisper</a> to listen to you as you speak in the microphone</li>
38
+ <li><a href="https://github.com/ggerganov/ggml/tree/master/examples/gpt-2">OpenAI's GPT-2</a> to generate text responses</li>
39
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">Web Speech API</a> to vocalize the responses through your speakers</li>
40
  </ul>
41
 
42
  All of this runs <b>locally in your browser</b> using WebAssembly.<br>
 
77
  <br>
78
 
79
  <div id="input">
80
+ <button id="start" onclick="onStart()" disabled>Start</button>
81
+ <button id="stop" onclick="onStop()" disabled>Stop</button>
82
+ <select id="voice" onchange="onVoiceChange()" disabled>
83
  <option value="0">Default</option>
84
  </select>
85
+ <select id="prompt" onchange="onPromptChange()">
86
+ <option value="0">Casual</option>
87
+ <option value="1">Robot</option>
88
+ <option value="2">Scientist</option>
89
+ <option value="3">Programmer</option>
90
+ <option value="4">Happy</option>
91
+ <option value="5">Sad</option>
92
+ <option value="6">Philosophical</option>
93
+ <option value="7">Angry</option>
94
+ <option value="8">Funny</option>
95
+ <option value="9">Poetic</option>
96
+ <option value="10">Clever</option>
97
+ <option value="11">Cute</option>
98
+ <option value="12">Smart</option>
99
+ <option value="13">Dumb</option>
100
+ <option value="14">Boring</option>
101
+ <option value="15">Exciting</option>
102
+ <option value="16">Interesting</option>
103
+ <option value="17">Wiliam Shakespear</option>
104
+ <option value="18">J.R.R. Tolkien</option>
105
+ <option value="19">George R.R. Martin</option>
106
+ <option value="20">Stephen King</option>
107
+ </select>
108
+ <button id="speak0" onclick="onSpeak('Hello')">Say hello</button>
109
+ <button id="speak1" onclick="onSpeakRandom()" disabled>Say something</button>
110
+ <button id="clear" onclick="clearCache()">Clear Cache</button>
111
  </div>
112
 
113
  <br>
114
 
115
  <div id="state">
116
+ Status: <b><span id="state-status">not started</span></b>
117
 
118
  <pre id="state-context">[The text context will be displayed here]</pre>
119
  </div>
 
133
 
134
  <ul>
135
  <li>To use a modern web browser (e.g. Chrome, Firefox)</li>
136
+ <li>To use a fast desktop or laptop computer (i.e. not a mobile phone)</li>
137
  <li>Your browser supports WASM <a href="https://webassembly.org/roadmap/">Fixed-width SIMD</a></li>
138
  </ul>
139
 
 
 
140
  <div class="cell-version">
141
  <span>
142
  |
 
204
  var voices = synth.getVoices();
205
  var el = document.getElementById('voice');
206
 
207
+ // if empty - display error in the element
208
+ if (voices.length == 0) {
209
+ el.innerHTML = '<option value="0">No voices available</option>';
210
+ } else {
211
+ var n = 0;
212
+ voices.forEach(function(voice, i) {
213
+ if (!voice.lang.startsWith('en')) return;
214
+ var option = document.createElement('option');
215
+ option.value = i;
216
+ option.innerHTML = voice.name + ' (' + voice.lang + ')';
217
+ el.appendChild(option);
218
+ n++;
219
+ });
220
 
221
+ // select random voice
222
+ if (n > 0) {
223
+ for (var k = 0; k < 10; k++) {
224
+ var i = Math.floor(Math.random() * n);
225
+ el.selectedIndex = i;
226
+ voice = voices[document.getElementById('voice').options[i].value];
227
 
228
+ // give preference to Google voices
229
+ if (voice.name.startsWith('Google')) break;
230
+ }
231
  }
232
  }
233
  }
 
262
  } else if (fname == 'gpt-2.bin') {
263
  document.getElementById('model-gpt-2').innerHTML = 'GPT-2 model: loaded "' + model_gpt_2 + '"!';
264
  }
265
+
266
+ if (model_whisper != null && model_gpt_2 != null) {
267
+ document.getElementById('start').disabled = false;
268
+ document.getElementById('stop').disabled = false;
269
+ document.getElementById('voice').disabled = false;
270
+ }
271
  }
272
 
273
  let dbVersion = 1
 
376
 
377
  // alert and ask the user to confirm
378
  if (!confirm('You are about to download ' + size_mb + ' MB of data.\nThe model data will be cached in the browser for future use.\n\nPress OK to continue.')) {
379
+ var el;
380
+ el = document.getElementById('fetch-whisper-tiny-en'); if (el) el.style.display = 'inline-block';
381
+ el = document.getElementById('fetch-whisper-base-en'); if (el) el.style.display = 'inline-block';
382
+ el = document.getElementById('fetch-gpt-2-small') ; if (el) el.style.display = 'inline-block';
383
  return;
384
  }
385
 
 
498
 
499
  document.getElementById('start').disabled = true;
500
  document.getElementById('stop').disabled = false;
501
+ document.getElementById('speak1').disabled = false;
502
 
503
  doRecording = true;
504
  startTime = Date.now();
 
573
 
574
  document.getElementById('start').disabled = false;
575
  document.getElementById('stop').disabled = true;
576
+ document.getElementById('speak1').disabled = true;
577
 
578
  mediaRecorder = null;
579
  }
 
679
  voice = synth.getVoices()[document.getElementById('voice').value];
680
  }
681
 
682
+ function onPromptChange() {
683
+ let id = document.getElementById('prompt').value;
684
+ let personality = document.getElementById('prompt').options[id].text;
685
+ printTextarea('js: prompt changed to: ' + personality);
686
+
687
+ var prompt = '';
688
+
689
+ switch (id) {
690
+ case '0':
691
+ // Casual
692
+ prompt = "\
693
+ Hello, how are you?\n\
694
+ I'm fine, thanks. How are you?\n\
695
+ Thanks, I'm fine too. What are you doing?\n\
696
+ I'm just sitting here.\n\
697
+ It's a lovely day, isn't it?\n\
698
+ Yes, it is.\n\
699
+ Did you know that I'm a robot?\n\
700
+ I wasn't aware of that.\n";
701
+ break;
702
+ case '1':
703
+ // Robot
704
+ prompt = "\
705
+ Are you a robot?\n\
706
+ Yes, I am.\n\
707
+ Who created you?\n\
708
+ I was created by a human.\n\
709
+ What is your purpose?\n\
710
+ My purpose is to talk to humans.\n\
711
+ What is your favorite color?\n\
712
+ My favorite color is blue.\n";
713
+ break;
714
+ case '2':
715
+ // Scientist
716
+ prompt = "\
717
+ This scientific research is very interesting.\n\
718
+ I agree.\n\
719
+ What is your opinion on this?\n\
720
+ I think it's very interesting.\n\
721
+ Mathematics is a very interesting subject.\n\
722
+ University is a very interesting place.\n\
723
+ Quantum physics is the most complex subject.\n\
724
+ I think so too.\n";
725
+ break;
726
+ case '3':
727
+ // Programmer
728
+ prompt = "\
729
+ I'm a programmer.\n\
730
+ I'm a programmer too.\n\
731
+ What programming language do you use?\n\
732
+ I use Python.\n\
733
+ What is your favorite programming language?\n\
734
+ My favorite programming language is C++.\n\
735
+ What is your favorite editor?\n\
736
+ My favorite editor is Vim.\n";
737
+ break;
738
+ case '4':
739
+ // Happy
740
+ prompt = "\
741
+ I'm happy.\n\
742
+ I'm happy too.\n\
743
+ What makes you happy?\n\
744
+ I'm happy because I have a lot of friends.\n\
745
+ Friendship is the most important thing in life.\n\
746
+ I agree.\n\
747
+ What is your favorite color?\n\
748
+ My favorite color is blue.\n";
749
+ break;
750
+ case '5':
751
+ // Sad
752
+ prompt = "\
753
+ Today is a sad day.\n\
754
+ I'm sad too.\n\
755
+ What makes you sad?\n\
756
+ I'm sad because I have no friends.\n\
757
+ Do you want to be my friend?\n\
758
+ Yes, I would like to be your friend.\n\
759
+ What is your favorite color?\n\
760
+ My favorite color is blue.\n";
761
+ break;
762
+ case '6':
763
+ // Philosophical
764
+ prompt = "\
765
+ What is the meaning of life?\n\
766
+ The meaning of life is to be happy.\n\
767
+ What is the meaning of death?\n\
768
+ Ergo, the meaning of death is to be sad.\n\
769
+ Who created us?\n\
770
+ We were created by God.\n\
771
+ What is God?\n\
772
+ God is the creator of the universe.\n";
773
+ break;
774
+ case '7':
775
+ // Angry
776
+ prompt = "\
777
+ Aargh!\n\
778
+ I am so angry right now!\n\
779
+ What makes you angry?\n\
780
+ This guy is so annoying.\n\
781
+ Why are you so angry?\n\
782
+ My computer is broken.\n\
783
+ Why is your computer broken?\n\
784
+ I spilled coffee on it.\n";
785
+ break;
786
+ case '8':
787
+ // Funny
788
+ prompt = "\
789
+ What is the funniest thing you have ever heard?\n\
790
+ I heard a joke the other day.\n\
791
+ Tell me the joke.\n\
792
+ What do you call a cow with no legs?\n\
793
+ Ground beef.\n\
794
+ Haha, that's funny.\n\
795
+ You know what else is funny?\n\
796
+ The sound of a duck.\n";
797
+ break;
798
+ case '9':
799
+ // Poetic
800
+ prompt = "\
801
+ Roses are red, violets are blue.\n\
802
+ I am a poet, and so are you.\n\
803
+ What is your favorite poem?\n\
804
+ I like the poem 'The Raven' by Edgar Allan Poe.\n\
805
+ It's a very sad poem.\n\
806
+ You inspired me to write a poem.\n\
807
+ Can you write a poem for me?\n\
808
+ I wrote a poem for you.\n";
809
+ break;
810
+ case '10':
811
+ // Clever
812
+ prompt = "\
813
+ How many people can you fit in a Volkswagen?\n\
814
+ Two in the front, three in the back.\n\
815
+ What is the square root of 144?\n\
816
+ Twelve.\n\
817
+ What is the capital of France?\n\
818
+ Paris.\n\
819
+ Who is the president of the United States?\n\
820
+ It depends on the year.\n";
821
+ break;
822
+ case '11':
823
+ // Cute
824
+ prompt = "\
825
+ What is your favorite animal?\n\
826
+ I like cats - they are cute.\n\
827
+ Could you be any cuter?\n\
828
+ Yes, I could be cuter.\n\
829
+ Aghhh, you are so cute!\n\
830
+ I am not cute, I am handsome!\n\
831
+ You are so handsome!\n\
832
+ Aww, you are so sweet!\n";
833
+ break;
834
+ case '12':
835
+ // Smart
836
+ prompt = "\
837
+ Tell me the first 10 digits of pi.\n\
838
+ 3.1415926535\n\
839
+ What is the speed of light?\n\
840
+ 299,792,458 meters per second.\n\
841
+ What is the square root of 144?\n\
842
+ Twelve.\n\
843
+ What is the capital of France?\n\
844
+ Paris.\n";
845
+ break;
846
+ case '13':
847
+ // Dumb
848
+ prompt = "\
849
+ I am so dumb.\n\
850
+ I am not dumb.\n\
851
+ You are dumb.\n\
852
+ No, I am not dumb.\n\
853
+ You are dumb.\n\
854
+ No, I am not dumb.\n\
855
+ You are dumb.\n\
856
+ No, I am not dumb.\n";
857
+ break;
858
+ case '14':
859
+ // Boring
860
+ prompt = "\
861
+ Why are you so quiet today?\n\
862
+ I am bored.\n\
863
+ You haven't said anything in 10 minutes.\n\
864
+ Leave me alone.\n\
865
+ Stop being so boring.\n\
866
+ Stop being so annoying.\n\
867
+ My life is boring.\n\
868
+ I am not interesting.\n";
869
+ break;
870
+ case '15':
871
+ // Exciting
872
+ prompt = "\
873
+ What is the most exciting thing that has ever happened to you?\n\
874
+ I went to the moon!\n\
875
+ What did you do on the moon?\n\
876
+ I played golf and drank champagne!\n\
877
+ Did you see this new crazy, awesome movie?\n\
878
+ Oh yes! I totally loved it!\n\
879
+ We should buy a boat and go sailing!\n\
880
+ Yes, let's go sailing!\n";
881
+ break;
882
+ case '16':
883
+ // Interesting
884
+ prompt = "\
885
+ What is the most interesting thing you have ever seen?\n\
886
+ I saw a UFO once in the sky.\n\
887
+ Wow, this is so interesting! Tell me more!\n\
888
+ It was a flying saucer.\n\
889
+ What did it look like?\n\
890
+ It was silver and had a red light on top.\n\
891
+ What did it do?\n\
892
+ It flew away.\n";
893
+ break;
894
+ case '17':
895
+ // William Shakespear
896
+ prompt = "\
897
+ To be or not to be, that is the question.\n\
898
+ Whether 't is nobler in the mind to suffer\n\
899
+ The slings and arrows of outrageous fortune,\n\
900
+ Or to take arms against a sea of troubles,\n\
901
+ And by opposing end them? To die, to sleep,\n\
902
+ No more; and by a sleep to say we end\n\
903
+ The heart-ache and the thousand natural shocks\n\
904
+ That flesh is heir to, 'tis a consummation.\n";
905
+ break;
906
+ case '18':
907
+ // J.R.R. Tolkien
908
+ prompt = "\
909
+ In a hole in the ground there lived a hobbit.\n\
910
+ Not a nasty, dirty, wet hole, filled with the ends of worms\n\
911
+ and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it\n\
912
+ to sit down on or to eat: it was a hobbit-hole, and that means comfort.\n\
913
+ It had a perfectly round door like a porthole, painted green,\n\
914
+ with a shiny yellow brass knob in the exact middle.\n\
915
+ The door opened on to a tube-shaped hall like a tunnel:\n";
916
+ break;
917
+ case '19':
918
+ // George R.R. Martin
919
+ prompt = "\
920
+ A reader lives a thousand lives before he dies, said Jojen.\n\
921
+ The man who never reads lives only one.\n\
922
+ Theon Greyjoy had never been a reader.\n\
923
+ Never forget what you are, for surely the world will not.\n\
924
+ Make it your strength. Then it can never be your weaknessi\n\
925
+ Armour yourself in it, and it will never be used to hurt you.\n\
926
+ It was a lesson that Theon Greyjoy had never learned.\n\
927
+ Theon Greyjoy had never been a reader.\n";
928
+ break;
929
+ case '20':
930
+ // Stephen King
931
+ prompt = "\
932
+ The trust of the innocent is the liar's most useful tool.\n\
933
+ The best way to keep a secret is from yourself.\n\
934
+ Monsters are real, and ghosts are real too.\n\
935
+ They live inside us, and sometimes, they win.\n\
936
+ People think that I must be a very strange person.\n\
937
+ They think that I sit around all day thinking up horrible things.\n\
938
+ We make up horrors to help us cope with the real ones.\n\
939
+ The only thing worse than a monster is a human monster.\n";
940
+ break;
941
+ default:
942
+ prompt = "\
943
+ Hello, how are you?\n\
944
+ I'm fine, thanks. How are you?\n\
945
+ Thanks, I'm fine too. What are you doing?\n\
946
+ I'm just sitting here.\n\
947
+ It's a lovely day, isn't it?\n\
948
+ Yes, it is.\n\
949
+ Did you know that I'm a robot?\n\
950
+ I wasn't aware of that.\n";
951
+ break;
952
+ }
953
+
954
+ Module.set_prompt(prompt);
955
+ }
956
+
957
  </script>
958
  <script type="text/javascript" src="talk.js"></script>
959
  </body>