-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbml.html
More file actions
1068 lines (739 loc) · 35.3 KB
/
bml.html
File metadata and controls
1068 lines (739 loc) · 35.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html>
<head>
<title>BML Realizer</title>
</head>
<body>
<div style="margin-left: 15%; margin-right: 15%; margin-top: 5%; margin-bottom: 5%;">
<h1>BML 1.0 Standard - BML Realizer</h1>
<p>This is an informative page about how to send messages to the virtual characters and the current state of the BML Realizer. An example of a virtual character (character = "KRISTINA") can be found in http://webglstudio.org/gerard/bml/. The current implementation supports:</p>
<ul>
<li>blinks</li>
<li>face, faceShift and facial lexemes</li>
<li>gaze and gazeShift</li>
<li>head and headDirectionShift</li>
<li>language-generation (H2020 Kristina)</li>
<li>Synchronization references</li>
<li>Composition modes</li>
</ul>
<p>Future planned features:</p>
<ul>
<li>gestures</li>
<li>posture</li>
<li>speech</li>
<li>other synchronization features (contraint, synchronize, wait, after, before, required)</li>
</ul>
<p>To send messages you need to send a POST to https://webglstudio.org:8080/bml (application/json) with a BML container and instructions. The response from the petition will be sent once the block has finished.</p>
<p>A better description might be found in <a href="http://www.mindmakers.org/projects/bml-1-0/wiki/Wiki"><em>BML 1.0 Standard</em></a> although not all features are implemented in the current version. Please revise the following document to check if the desired feature is available and how is the syntax</p>
<h2>BML block/container</h2>
<p>In contrast with the BML 1.0 Standard, this implementation uses JSON encoding instead of XML. Nevertheless, the current server converts XML to JSON, so XML messages should be accepted too.</p>
<p>Each BML container should have an <em>id</em> and the character name (KRISTINA by default). Inside the bml container there will be the bml instructions. Additionally the composition mode could be specified (MERGE, APPEND, REPLACE). Read at the end of the document for further information.</p>
<p>var BMLBlock = {</p>
<p style="margin-left: 40px;">id: <em>myBlockId</em>,</p>
<p style="margin-left: 40px;">character: "KRISTINA", </p>
<p style="margin-left: 40px;">composition: "MERGE",</p>
<p style="margin-left: 40px;"><em>bml instructions</em>...</p>
<p>}</p>
<h3>H2020 KRISTINA EXCEPTION</h3>
<p>Messages should be sent to https://webglstudio.org:8080/idle (application/json), to https://webglstudio.org:8080/turn (application/json) and/or to https://webglstudio.org:8080/avatar (application/json). The character name should be inside the <em>meta</em> object as <em>avatar</em> , the id called <em>uuid</em> and the BML instructions and composition should be inside <em>data</em>.</p>
<p><u>BML instructions (idle)</u></p>
<p>var BMLKristinaBlock = {</p>
<p style="margin-left: 40px;">meta: {</p>
<p style="margin-left: 80px;">avatar: "KRISTINA"</p>
<p style="margin-left: 40px;">},</p>
<p style="margin-left: 40px;">uuid: <em>myBlockId</em>,</p>
<p style="margin-left: 40px;">data: {</p>
<p style="margin-left: 80px;">state: "WAITING",</p>
<p style="margin-left: 80px;"><em>bml instructions...</em></p>
<p style="margin-left: 80px;">composition: "MERGE"</p>
<p style="margin-left: 40px;">}</p>
<p>}</p>
<h3>Test your XML files here</h3>
<p>Drag and drop your log files in the box to test them:</p>
<div id="dropZoneXML" style="width:100px;height:60px; background-color: whitesmoke;border: 2px dashed black; border-radius: 5px"> </div>
<p> </p>
<ul id="XMLList"></ul>
<p><script>
// Drop log files and send them
// Drop
var dropZoneXML = document.getElementById('dropZoneXML');
//var logList = document.getElementById('logList');
// Object with file data
document.files = {};
dropZoneXML.addEventListener('dragover', function(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
});
dropZoneXML.addEventListener('drop', function(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files; // Array of all files
for (var i=0, file; file=files[i]; i++) {
// Should create the buttons to send the .json files
var s = file.name.split(".");
var ext = s[s.length-1];
console.log("File dropped: ", file.name);
if (ext == "xml"){
var reader = new FileReader();
reader.filename = file.name;
reader.onload = function(e2){
// Create buttons
var button = document.createElement("input");
button.type = "button";
button.name = "file" + i;
button.value = this.filename;
button.onclick = function(){
var msg = document.files[this.value];
sendToServerXML(msg);
}
document.files[this.filename] = e2.target.result;
var logList = document.getElementById('XMLList');
var listElement = document.createElement('li');
listElement.style = "margin-top: 10px";
listElement.appendChild(button);
logList.appendChild(listElement);
}
reader.readAsText(file);
}
//if (file.type.match(/image.*/)) {
/* var reader = new FileReader();
reader.onload = function(e2) { // finished reading file data.
var img = document.createElement('img');
img.src= e2.target.result;
document.body.appendChild(img);
}
reader.readAsDataURL(file); // start reading the file data.
} */
}
});
// get logs
</script></p>
<p> </p>
<p> </p>
<script>
function sendToServerXML(msg){
req = new XMLHttpRequest();
req.open('POST', 'https://webglstudio.org:8080/bml', true);
req.setRequestHeader("Content-type", "text/xml;charset=UTF-8");
req.timeout = 10000;
req.ontimeout = function(){console.log("Timed out")};
req.send(msg);
req.onreadystatechange = function () { //Call a function when the state changes.
if (req.readyState == 4 && req.status == 200) {
console.log(req.responseText);
}
}
}
</script>
<p><u>Turn instructions (turn)</u></p>
<p>The format of the turn message should always include the variable control which represent the different states of the agent. Control can take the values of WAITING, LISTENING, PROCESSING, UNDERSTANDING, PLANNING and SPEAKING.</p>
<p>A message with language-generation information should take this form:</p>
<p>var BMLKristinaLanguageGeneration = {</p>
<p style="margin-left: 40px;">meta: { avatar: "KRISTINA" },</p>
<p style="margin-left: 40px;">uuid: <em>myBlockId</em>,</p>
<p style="margin-left: 40px;">data: {</p>
<p style="margin-left: 80px;">state: "SPEAKING",</p>
<p style="margin-left: 80px;">vocapia-data: {text: <em>userInput</em>},</p>
<p style="margin-left: 80px;">mode-selection: {</p>
<p style="margin-left: 120px;">nonverbal: {0: <em>rdfString</em>, 1: <em>rdfString</em>...}</p>
<p style="margin-left: 80px;">},</p>
<p style="margin-left: 80px;">language-generation: [</p>
<p style="margin-left: 120px;">{</p>
<p style="margin-left: 160px;">id: <i>speech0</i>,</p>
<p style="margin-left: 160px;">start: 0,</p>
<p style="margin-left: 160px;">end: <i>audio duration</i>,</p>
<p style="margin-left: 160px;">text: <em>agentSpeech</em>,</p>
<p style="margin-left: 160px;">textTiming: <em>array with text, start and end times</em>,</p>
<p style="margin-left: 160px;">audioURL: <em>url of audio file,</em></p>
<p style="margin-left: 160px;">duration: <em>audio duration,</em></p>
<p style="margin-left: 160px;">valence: <i>msg's valence</i>,</p>
<p style="margin-left: 160px;">arousal: <em>msg's arousal</em>,</p>
<p style="margin-left: 160px;">sequence: <em>array with l</em><em>ipsync data</em>,</p>
<p style="margin-left: 120px;">},</p>
<p style="margin-left: 120px;"><em>other speech instructions...</em></p>
<p style="margin-left: 80px;">]</p>
<p style="margin-left: 40px;">}</p>
<p>}</p>
<p><u>Chaning the state of the agent</u></p>
<p>The state of the agent is changed by adding the parameter <em>control </em>to the messages. You can press this buttons to see how the behavior changes in the web applicaiton.</p>
<table align="center" border="0" cellpadding="1" cellspacing="1" style="width:100%;">
<tbody>
<tr>
<td style="text-align: center;"><input name="control1" onclick="sendControl('WAITING')" type="button" value="WAITING" /></td>
<td style="text-align: center;"><input name="control2" onclick="sendControl('LISTENING')" type="button" value="LISTENING" /></td>
<td style="text-align: center;"><input name="control3" onclick="sendControl('PROCESSING')" type="button" value="PROCESSING" /></td>
<td style="text-align: center;"><input name="control4" onclick="sendLG()" type="button" value="SPEAKING" /></td>
</tr>
</tbody>
</table>
<h3>Test your log files here</h3>
<p>Drag and drop your log files in the box to test them:</p>
<div id="dropZone" style="width:100px;height:60px; background-color: whitesmoke;border: 2px dashed black; border-radius: 5px"> </div>
<p> </p>
<ul id="logList"></ul>
<p><script>
// Drop log files and send them
// Drop
var dropZone = document.getElementById('dropZone');
//var logList = document.getElementById('logList');
// Object with file data
document.files = {};
dropZone.addEventListener('dragover', function(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
});
dropZone.addEventListener('drop', function(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files; // Array of all files
for (var i=0, file; file=files[i]; i++) {
// Should create the buttons to send the .json files
var s = file.name.split(".");
var ext = s[s.length-1];
console.log("File dropped: ", file.name);
if (ext == "json"){
var reader = new FileReader();
reader.filename = file.name;
reader.onload = function(e2){
// Create buttons
var button = document.createElement("input");
button.type = "button";
button.name = "file" + i;
button.value = this.filename;
button.onclick = function(){
var msg = document.files[this.value];
sendToServer(JSON.parse(msg));
}
document.files[this.filename] = e2.target.result;
var logList = document.getElementById('logList');
var listElement = document.createElement('li');
listElement.style = "margin-top: 10px";
listElement.appendChild(button);
logList.appendChild(listElement);
}
reader.readAsText(file);
}
//if (file.type.match(/image.*/)) {
/* var reader = new FileReader();
reader.onload = function(e2) { // finished reading file data.
var img = document.createElement('img');
img.src= e2.target.result;
document.body.appendChild(img);
}
reader.readAsDataURL(file); // start reading the file data.
} */
}
});
// get logs
</script></p>
<p> </p>
<p> </p>
<hr />
<hr />
<h2>BML Instructions</h2>
<p>Each BML instruction should have several synchronization attributes (<em>start, end</em>) and an <em>id</em>.</p>
<h3>blink</h3>
<p>Makes the virtual character blink to a specified amount (default 1). The blink instruction can have four sync attributes (<em>start, attackPeak, relax </em>and <em>end</em>). The <strong><em>amount</em> </strong>attribute defines how much the eye should be closed.</p>
<p>blink = {</p>
<p style=" margin-left:=">id: " blink1",</p>
<p> </p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">attackPeak: 0.1,</p>
<p style="margin-left: 40px;">relax: 0.1,</p>
<p style="margin-left: 40px;">end: 0.5,</p>
<p style="margin-left: 40px;">amount: 1</p>
<p>}</p>
<hr />
<h3>face</h3>
<p>The virtual character will show a facial expression and return back to its original state. The face instruction has four sync attributes (<em>start, attackPeak, relax </em>and <em>end</em>). The facial expression is defined by an array with two values, <strong><em>valaro </em></strong>(in reference to the valence-arousal model). The first value of the array represents valence (range -1, 1) and the second arousal (range -1, 1). Alternatively specific facial blend shapes could be controlled independently through <strong><em>lexeme </em></strong>(explained below).</p>
<p>face = {</p>
<p style="margin-left: 40px;">id: "face1",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">attackPeak: 0.8,</p>
<p style="margin-left: 40px;">relax: 1.2,</p>
<p style="margin-left: 40px;">end: 2,</p>
<p style="margin-left: 40px;">valaro: [0.5, 0.5]</p>
<p>}</p>
<h3>faceShift</h3>
<p>The virtual character will shift to a facial expression and remain with it. The faceShift instruction has two sync attributes (<em>start </em>and <em>end</em>). The facial expression is defined by an array with two values, <strong><em>valaro </em></strong>(in reference to the valence-arousal model). The first value of the array represents valence (range -1, 1) and the second arousal (range -1, 1). Alternatively specific facial blend shapes could be controlled independently through <strong><em>lexeme </em></strong>(explained below).</p>
<p>faceShift = {</p>
<p style="margin-left: 40px;">id: "face2",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">end: 1,</p>
<p style="margin-left: 40px;">valaro: [-0.5, -0.5]</p>
<p>}</p>
<h3>lexeme (inside face or faceShift)</h3>
<p>Inside the BML instructions face and faceShift the <em><strong>lexeme</strong></em> attribute can be added to control specific blend shapes. Each <em><strong>lexeme</strong></em> has two attributes: <em><strong>lexeme</strong></em> and <b><i>amount</i></b>. The first is a string defining which blend shape to control, the second is the amount of deformation (default 1). Available lexemes are: <em>LOWER_MOUTH_CORNERS, RAISE_MOUTH_CORNERS, OPEN_LIPS, OPEN_MOUTH, LOWER_BROWS, OBLIQUE_BROWS, RAISE_BROWS, WIDEN_EYES, CLOSE_EYES.</em></p>
<p>faceShift = {</p>
<p style="margin-left: 40px;">id: "face3",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">end: 1,</p>
<p style="margin-left: 40px;">lexeme: {</p>
<p style="margin-left: 80px;">lexeme: "RAISE_MOUTH_CORNERS",</p>
<p style="margin-left: 80px;">amount: 1</p>
<p style="margin-left: 40px;">}</p>
<p>}</p>
<p>Several lexemes can be controlled at the same time too:</p>
<p>face = {</p>
<p style="margin-left: 40px;">id: "face4",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">attackPeak: 0.5,</p>
<p style="margin-left: 40px;">relax: 1.5,</p>
<p style="margin-left: 40px;">end: 2,</p>
<p style="margin-left: 40px;">lexeme: [</p>
<p style="margin-left: 80px;">{lexeme: "OBLIQUE_BROWS", amount: 0.5},</p>
<p style="margin-left: 80px;">{lexeme: "CLOSE_EYES", amount: 0.3},</p>
<p style="margin-left: 80px;">{lexeme: "RAISE_MOUTH_CORNERS", amount: 0.7}</p>
<p style="margin-left: 40px;">]</p>
<p>}</p>
<hr />
<h3>gaze</h3>
<p>The virtual character will change its gaze direction and return to its starting position. The gaze instruction has four sync attributes (<em>start, ready, relax </em>and <em>end</em>). Several other attributes can be defined: <em><strong>influence, target, offsetAngle, </strong></em><b><i>offsetDirection</i></b> and <b><i>dynamic</i></b>.</p>
<p><em><strong>influence</strong></em> defines which part of the body should move and switch gaze. In the current implementation only <em>EYES </em>and <em>HEAD</em> are available. If the influence is set to <em>HEAD</em> the eyes will also turn. <em><strong>target</strong></em> defines where the virtual character should look: <em>RIGHT, LEFT, UP, DOWN, UPRIGHT, UPLEFT, DOWNRIGHT, DOWNLEFT </em>and<em> CAMERA</em>. The gaze target position can be modified by <em><strong>offsetAngle</strong></em> (degrees to turn away from target) and <em><strong>offsetDirection</strong></em> (direction to deviate). <em><strong>offsetDirection</strong></em> can be <em>RIGHT, LEFT, UP, DOWN, UPRIGHT, UPLEFT, DOWNRIGHT, DOWNLEFT. </em>If there is a moving target in the scene, <strong>dynamic</strong> can be set to true to make the gaze follow.</p>
<p>gaze = {</p>
<p style="margin-left: 40px;">id: "gaze1",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">ready: 0.8,</p>
<p style="margin-left: 40px;">relax: 1.3,</p>
<p style="margin-left: 40px;">end: 2,</p>
<p style="margin-left: 40px;">influence: "EYES",</p>
<p style="margin-left: 40px;">target: "CAMERA",</p>
<p style="margin-left: 40px;">offsetAngle: 15,</p>
<p style="margin-left: 40px;">offsetDirection: "RIGHT"</p>
<p>}</p>
<h3>gazeShift</h3>
<p>The virtual character will change its gaze direction and remain there. The gazeShift instruction has two sync attributes (<em>start </em>and <em>end</em>). Several other attributes can be defined as in BML instruction gaze: <em><strong>influence, target, offsetAngle, </strong></em><b><i>offsetDirection</i></b> and <b><i>dynamic</i></b>.</p>
<p>gazeShift = {</p>
<p style="margin-left: 40px;">id: "gaze2",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">end: 1,</p>
<p style="margin-left: 40px;">influence: "HEAD",</p>
<p style="margin-left: 40px;">target: "DOWN"</p>
<p>}</p>
<hr />
<h3>headDirectionShift</h3>
<p>Permits to turn just the head and keep the eyes in the same position. The virtual character will move it's head towards the target and remain there. The headDirectionShift instruction has two sync attributes (<em>start </em>and <em>end</em>). Several other attributes can be defined as in BML instruction gaze but influence: <em><strong>target, offsetAngle, </strong></em><b><i>offsetDirection</i></b> and <b><i>dynamic</i></b>.</p>
<p>headDirectionShift = {</p>
<p style="margin-left: 40px;">id: "head1",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">end: 1,</p>
<p style="margin-left: 40px;">target: "CAMERA",</p>
<p style="margin-left: 40px;">offsetAngle: 10,</p>
<p style="margin-left: 40px;">offsetDirection: "DOWNLEFT"</p>
<p>}</p>
<h3>head</h3>
<p>The virtual character will perform head gestures. The head instruction has seven sync attributes (<em>start, ready, strokeStart, stroke, strokeEnd, relax, end</em>). The type of gesture will be defined by <em><strong>lexeme</strong></em> (<em>NOD, SHAKE, TILT</em>). Each gesture can be repeated more than once by <b><i>repetition</i></b> (default 0). If <em><strong>repetition</strong></em> is different than 0 the sync attribute <em>stroke</em> is not needed (as the repetition will happen between <em>strokeStart and </em><em>strokeEnd</em>). The attribute <em><strong>amount</strong></em> defnies the intensity of the head gesture.</p>
<p>head = {</p>
<p style="margin-left: 40px;">id: "head2",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">ready: 0.3,</p>
<p style="margin-left: 40px;">strokeStart: 0.3,</p>
<p style="margin-left: 40px;">stroke: 1,</p>
<p style="margin-left: 40px;">strokeEnd: 1.6,</p>
<p style="margin-left: 40px;">relax: 1.6,</p>
<p style="margin-left: 40px;">end: 2,</p>
<p style="margin-left: 40px;">lexeme: "NOD",</p>
<p style="margin-left: 40px;">repetition: 0,</p>
<p style="margin-left: 40px;">amount: 0.6</p>
<p>}</p>
<p><img alt="" src="http://www.mindmakers.org/attachments/download/238" /></p>
<p> </p>
<hr />
<h3>lg (language-generation for KRISTINA)</h3>
<p>From the KRISTINA project, the virtual character can reproduce audio and lipsyncing through a specific format. The lg instruction has two sync attributes (<em>start </em>and <em>end</em>). Other attributes are <em><strong>audioURL, sequence, text, textTiming, valence</strong></em> and <b><i>arousal</i></b>. <em><strong>audioURL</strong></em> is a "https" link to an audio file with the speech; <em><strong>sequence</strong></em><em> </em>is an array of vectors containing information of lip shapes (timestamp, jaw, smile, mouth air, lips closed, kiss, sad); <strong><em>text</em></strong> is the transcription of the speech; <em><strong>textTiming</strong></em> is an array of three components: an array with each transcribed word, an array with start timestamps for each word and an array with end timestamps for each word. The timestamps correspond to the speech audio file; <em><strong>valence </strong></em>and <b><i>arousal </i></b>are the emotional cue to generate appropiate gestures.</p>
<p>lg = {</p>
<p style="margin-left: 40px;">id: "language_generation1",</p>
<p style="margin-left: 40px;">start: 0,</p>
<p style="margin-left: 40px;">end: 1,</p>
<p style="margin-left: 40px;">audioURL: <i>https link to the audio file,</i></p>
<p style="margin-left: 40px;">sequence: [</p>
<p style="margin-left: 80px;">[0, 0, 0, 0, 0, 0, 0],</p>
<p style="margin-left: 80px;">[0.1, 0.2, 0.1, 0, 0, 0, 0]</p>
<p style="margin-left: 80px;"><em>... more lipsync information</em></p>
<p style="margin-left: 40px;">],</p>
<p style="margin-left: 40px;">text: "Hello World",</p>
<p style="margin-left: 40px;">textTiming: [</p>
<p style="margin-left: 80px;">["Hello", "World"],</p>
<p style="margin-left: 80px;">[0, 0.5],</p>
<p style="margin-left: 80px;">[0.4, 1]</p>
<p style="margin-left: 40px;">],</p>
<p style="margin-left: 40px;">valence: 0.5,</p>
<p style="margin-left: 40px;">arousal: 0.2</p>
<p>}</p>
<p><input name="lg" onclick="sendLG()" type="button" value="Send lg sample" /></p>
<script>
function sendControl(state){
var msg = {
"uuid": "changeState",
"meta": {"avatar": "KRISTINA"},
"data": {"state": state}
}
sendToServer(msg);
}
var LGready = true;
function sendLG(){
if (!LGready)
return;
// How to send POST messages through webglstudio.org:8080
var msg = {
"type": "turn",
"uuid": Math.floor(Math.random()*1000),
"meta": {
"user": "Anna",
"avatar": "KRISTINA",
"scenario": "babycare",
"language": "de"
},
"data": {
"state": "SPEAKING",
"composition": "APPEND",
"mode-selection": {
"verbal": {
"0": "<rdf:RDF\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n xmlns:j.0=\"http://kristina-project.eu/ontologies/dialogue_actions#\" > \n <rdf:Description rdf:about=\"http://kristina-project.eu/tmp#2e411520-ca69-4827-bf56-a5c5b8ba650a\">\n <rdf:type rdf:resource=\"http://kristina-project.eu/ontologies/dialogue_actions#SimpleGreet\"/>\n <j.0:isBelief rdf:datatype=\"http://www.w3.org/2001/XMLSchema#boolean\">false</j.0:isBelief>\n <j.0:isAdvice rdf:datatype=\"http://www.w3.org/2001/XMLSchema#boolean\">false</j.0:isAdvice>\n <j.0:isFormal rdf:datatype=\"http://www.w3.org/2001/XMLSchema#boolean\">false</j.0:isFormal>\n <j.0:directness rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">1.0</j.0:directness>\n <j.0:verbosity rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">0.0</j.0:verbosity>\n </rdf:Description>\n <rdf:Description rdf:about=\"http://kristina-project.eu/tmp#a8022e97-ed10-441c-ad43-688ef60efd08\">\n <j.0:hasValence rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">0.23190759</j.0:hasValence>\n <j.0:hasArousal rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">0.25</j.0:hasArousal>\n <j.0:containsSystemAct rdf:resource=\"http://kristina-project.eu/tmp#2e411520-ca69-4827-bf56-a5c5b8ba650a\"/>\n <rdf:type rdf:resource=\"http://kristina-project.eu/ontologies/dialogue_actions#SystemAction\"/>\n </rdf:Description>\n</rdf:RDF>\n"
},
"nonverbal": {
"0": "<rdf:RDF\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n xmlns:j.0=\"http://kristina-project.eu/ontologies/dialogue_actions#\" > \n <rdf:Description rdf:about=\"http://kristina-project.eu/msins0\">\n <j.0:hasOrder rdf:datatype=\"http://www.w3.org/2001/XMLSchema#int\">0</j.0:hasOrder>\n <j.0:hasValence rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">0.23190759</j.0:hasValence>\n <j.0:hasArousal rdf:datatype=\"http://www.w3.org/2001/XMLSchema#float\">0.25</j.0:hasArousal>\n <rdf:type rdf:resource=\"http://kristina-project.eu/ontologies/dialogue_actions#SimpleGreet\"/>\n </rdf:Description>\n</rdf:RDF>\n"
}
},
"language-generation": [
{
"text": "Guten Tag! ",
"audioURL": "http://kristina.taln.upf.edu/synthesizer-service/resources/100.0.wav",
"duration": 0.7474166750907898,
"valence": 0,
"arousal": 0,
"sequence": [
[
0.05000000074505806,
0.03,
0.09,
0,
0.318,
0,
0
],
[
0.14000000059604645,
0.12,
0.05,
0,
0.99,
0,
0
],
[
0.21518750488758087,
0.072,
0.24,
0,
0,
0.06,
0
],
[
0.2916770875453949,
0.2,
0.47,
0,
0,
0,
0
],
[
0.36269789934158325,
0.108,
0.15,
0,
0,
0.24,
0
],
[
0.4399062395095825,
0.072,
0.24,
0,
0,
0.06,
0
],
[
0.5723958611488342,
0.18,
0.65,
0,
0,
0,
0
],
[
0.7024062871932983,
0.066,
0.09,
0,
0,
0.36,
0
],
[
0.7474166750907898,
0,
0,
0,
0,
0,
0
]
],
"textTiming": [
[
"guten",
"tag"
],
[
0,
0.39241665601730347
],
[
0.39241665601730347,
0.7474166750907898
]
],
"id": "speech0",
"start": "0.0",
"end": 0.7474166750907898
},
{
"text": "Gern geschehen. ",
"audioURL": "http://kristina.taln.upf.edu/synthesizer-service/resources/100.0.wav",
"duration": 0.9880000352859497,
"valence": 0,
"arousal": 0,
"sequence": [
[
0.02499999850988388,
0.03,
0.09,
0,
0.318,
0,
0
],
[
0.10509374737739563,
0.18,
0.65,
0,
0,
0,
0
],
[
0.19468750059604645,
0.048,
0.24599999999999997,
0,
0,
0,
0
],
[
0.273375004529953,
0.108,
0.15,
0,
0,
0.24,
0
],
[
0.3477916717529297,
0.03,
0.09,
0,
0.318,
0,
0
],
[
0.3930104076862335,
0.2,
0.47,
0,
0,
0,
0
],
[
0.4829999804496765,
0,
0.12,
0,
0.24,
0.15,
0
],
[
0.6629999876022339,
0.16,
0.55,
0,
0,
0,
0
],
[
0.7829999923706055,
0.2,
0.47,
0,
0,
0,
0
],
[
0.8930000066757202,
0.108,
0.15,
0,
0,
0.24,
0
],
[
0.9880000352859497,
0,
0,
0,
0,
0,
0
]
],
"textTiming": [
[
"gern",
"geschehen"
],
[
0,
0.3175625205039978
],
[
0.3175625205039978,
0.9880000352859497
]
],
"id": "speech1",
"start": "speech0:end",
"end": "speech0:end+0.9880000352859497"
}
]
}
}
sendToServer(msg);
}
// Send to server
function sendToServer(msg){
req = new XMLHttpRequest();
req.open('POST', 'https://webglstudio.org:8080/turn', true);
req.setRequestHeader("Content-type", "application/json;charset=UTF-8");
req.timeout = 10000;
req.ontimeout = function(){console.log("Timed out")};
req.send(JSON.stringify(msg));
req.onreadystatechange = function () { //Call a function when the state changes.
if (req.readyState == 4 && req.status == 200) {
console.log(req.responseText);
}
}
}
</script>
<hr />
<hr />
<h2>Synchronization</h2>
<p>Synchronization references to other bml instructions or blocks can be made. For example, we could define that a smile starts when a head nod reaches <em>stroke</em> sync attribute:</p>
<p>var BMLBlock = {</p>
<p style="margin-left: 40px;">id: "block1",</p>
<p style="margin-left: 40px;">character: "KRISTINA",</p>
<p style="margin-left: 40px;">head: {</p>
<p style="margin-left: 80px;">id: "head3",</p>
<p style="margin-left: 80px;">start: 0,</p>
<p style="margin-left: 80px;">ready: 0.3,</p>
<p style="margin-left: 80px;">strokeStart: 0.3,</p>
<p style="margin-left: 80px;">stroke: 1,</p>
<p style="margin-left: 80px;">strokeEnd: 1.6,</p>
<p style="margin-left: 80px;">relax: 1.6,</p>
<p style="margin-left: 80px;">end: 2,</p>
<p style="margin-left: 80px;">lexeme: "NOD",</p>
<p style="margin-left: 80px;">amount: 0.6</p>
<p style="margin-left: 40px;">},</p>
<p style="margin-left: 40px;">face: {</p>
<p style="margin-left: 80px;">id: "face5",</p>
<p style="margin-left: 80px;">start: "head3:stroke",</p>
<p style="margin-left: 80px;">attackPeak: "head3:stroke + 0.5",</p>
<p style="margin-left: 80px;">relax: "head3:stroke + 1",</p>
<p style="margin-left: 80px;">end: "head3:stroke + 1.5",</p>
<p style="margin-left: 80px;">valaro: [0.8, 0.1]</p>
<p style="margin-left: 40px;">}</p>
<p>}</p>
<p>Here is an example of synchronization references to the previous block:</p>
<p>var BMLBlock2 = {</p>
<blockquote>
<p>id: "block2",</p>
<p>character: "KRISTINA",</p>
<p>gazeShift: {</p>
<p style="margin-left: 40px;">id: "gaze3",</p>
<p style="margin-left: 40px;">start: "block1:face:relax",</p>
<p style="margin-left: 40px;">end: "block1:face:relax +1",</p>
<p style="margin-left: 40px;">influence: "EYES",</p>
<p style="margin-left: 40px;">target: "UPRIGHT",</p>
<p style="margin-left: 40px;">offsetAngle: "25",</p>
<p style="margin-left: 40px;">offsetDirection: "DOWNLEFT"</p>
<p>}</p>
</blockquote>
<p>}</p>
<hr />
<hr />
<h2>Composition Mode</h2>
<p>When a new block arrives (BML container) the individual BML instructions are added to a stack. The way they are added to the stack of pending actions can be chosen with the <em><strong>composition</strong></em> attribute in each block/container. It can be set to <em>MERGE, APPEND </em>and <i>REPLACE</i>. The first setting will try to merge the new block with the existing ones. If there is a conflict between the new BML instruction and the one in the stack the new BML instruction will be discarded. The <em>APPEND</em> mode will add the new block to the end of the BML stack. The <em>REPLACE</em> mode will be placed just after the current block being executed, removing all the following BML blocks.</p>
<p>The current implementation doesn't allow to interrupt an ongoing BML block. In the next version it will be possible to interrupt and to overwrite ongoing BML instructions.</p>
<p> </p>