-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
125 lines (122 loc) · 4.09 KB
/
index.html
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
<!doctype html>
<html>
<head>
<title id="title">stella.voice - initialising...</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
@font-face{
font-family: 'stella.typeface';
src: url('fonts/stellanorm.otf');
}
@font-face{
font-family: 'stella.typeface';
font-weight: bold;
src: url('fonts/stellabold.otf');
}
.loaded{
animation: loaded ease-out 0.2s;
animation-iteration-count: 1;
transform-origin: 50% 50%;
animation-fill-mode:forwards; /*when the spec is finished*/
-webkit-animation: loaded ease-out 0.2s;
-webkit-animation-iteration-count: 1;
-webkit-transform-origin: 50% 50%;
-webkit-animation-fill-mode:forwards; /*Chrome 16+, Safari 4+*/
-moz-animation: loaded ease-out 0.2s;
-moz-animation-iteration-count: 1;
-moz-transform-origin: 50% 50%;
-moz-animation-fill-mode:forwards; /*FF 5+*/
}
@keyframes loaded{
0% {
opacity:1;
}
100% {
opacity:0;
display: none;
width: 0;
height: 0;
}
}
@-moz-keyframes loaded{
0% {
opacity:1;
}
100% {
opacity:0;
display: none;
width: 0;
height: 0;
}
}
@-webkit-keyframes loaded {
0% {
opacity:1;
}
100% {
opacity:0;
display: none;
width: 0;
height: 0;
}
}
</style>
<script type="text/javascript">
function loadcall(){
document.getElementById("loading").setAttribute("class", "loaded");
document.getElementById("title").innerHTML = "stella.voice - ";
speechtranscript();
}
function speechtranscript(){
window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition;
if ('SpeechRecognition' in window) {
document.getElementById("greeting").innerHTML = "starting...";
} else {
document.getElementById("greeting").innerHTML = "stella.recognition unsupported.";
}
const recognition = new window.SpeechRecognition();
recognition.onresult = (event) => {
const speechToText = event.results[0][0].transcript;
document.getElementById("transcription").innerHTML = speechToText;
document.getElementById("mic").setAttribute("style", "width: 30px; padding-top: 0px; opacity: 0.5");
}
recognition.onend = (event) => {
document.getElementById("transcription").setAttribute("style", "text-align: right; font-family: 'stella.typeface', sans-serif; color: black; font-size: 25px;");
document.getElementById("mic").setAttribute("style", "width: 30px; padding-top: 0px; opacity: 1");
document.getElementById("greeting").remove();
setTimeout("sendtoconversation()", 3000);
}
recognition.interimResults = true;
recognition.start();
document.getElementById("mic").setAttribute("style", "width: 30px; padding-top: 0px; opacity: 0.5;");
document.getElementById("greeting").innerHTML = "I'm Listening...";
}
function sendtoconversation(){
document.getElementById("mic").setAttribute("style", "width: 30px; padding-top: 0px; opacity: 1;");
var input = document.getElementById("transcription").innerHTML
document.getElementById("transcription").innerHTML = " ";
var bubble = document.createElement('div');
document.getElementById("conversation").appendChild(bubble);
}
</script>
<body onLoad="loadcall()" style="overflow-x: hidden; margin: 0; background-color: white;">
<!-- START LOADING -->
<div id="loading" style="width: 100vw; height: 100vh; overflow-x: hidden; background-color: white; margin: 0;">
<img src="images/logo_gray.png" style="position: fixed; top: 35%; left: 37%; max-width: 20%;"></img>
</div>
<!-- END LOADING -->
<!-- START UI -->
<div style="margin: 0; height: 80vh" id="conversation">
<center>
<h1 id="greeting" style="font-family: 'stella.typeface', sans-serif; margin: 0; padding-top: 20px;">Hey There!</h1>
</center>
</div>
<div style="margin: 0; background-color: white; box-shadow: 0px -6px 11px 0px #888888;" id="navbar">
<p id="transcription" style="text-align: right; font-family: 'stella.typeface', sans-serif; color: gray; font-size: 25px;"> </p>
<center>
<img onClick="speechtranscript()" id="mic" style="width: 30px; padding-top: 0px;" src="images/logo_black.png">
</center>
</div>
</body>
</html>