-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
236 lines (193 loc) · 6.54 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
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
<!DOCTYPE html>
<html>
<head>
<title>cmd-f Voice</title>
<script src="../texttospeech_api.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
overflow:hidden;
}
.header {
position:relative;
background-color:lavender;
text-align:center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
margin-bottom:20px;
padding:10px;
color:darkgray;
}
/* button {
background-color: rgb(147, 133, 226);
border: none;
color: white;
padding: 5px 50px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 13px;*/
.urlsubmit {
margin:auto;
display:inline-block;
position: relative;
padding-bottom:20px;
text-align:center;
}
.title {
font-family: 'Courier New', Courier, monospace;
color:black;
font-size: 30px;
font-weight: 800;
}
.subtitle {
font-family: 'Courier New', Courier, monospace;
color:black;
}
.col {
float:left;
width:50%;
padding:50px;
}
.row:after {
content: "";
display: table;
clear: both;
}
@media screen and (max-width: 600px) {
.column {
width: 100%;
}
.buttonStyling {
display:block !important;
margin:10px;
}
}
.footer {
position:absolute;
bottom:0;
background-color:lavender;
text-align:center;
font-family: 'Courier New', Courier, monospace;
padding:10px;
height:150px;
width:100%;
color:darkgray;
}
.skiping {
margin:0px 70px;
display:block;
}
</style>
</head>
<title>CMD-F</title>
<body>
<!--HEADER-->
<div class="header">
<!--<img height="70" src="maingraphic.png">-->
<p class = "title">cmd-f my voice.</p>
<p class = "subtitle">locate key phrases in audio and video files and quickly jump to the parts you want.</p>
</div>
<div class="row">
<div class="col">
<!-- <span id="key-val">
key
</span>-->
<!-- <div class="video">
<iframe id="ytVideo" width="560" height="315"
src="https://www.youtube.com/embed/eDkpVwrhYfo" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>-->
<!--UPLOAD an audio file, upload file button will add to bucket-->
<form action="/uploadfile" enctype="multipart/form-data" method="POST">
<input id="upload" type="file" name="myFile" class="btn btn-outline-dark"/>
<input class="btn btn-outline-dark" type="submit" value="Upload a file"/>
</form>
<!--disply the audio bar, submit adds the time buttons-->
<audio id="sound" style="margin:30px" src="">
</audio>
<div class='skipping'>
<button class="btn btn-outline-dark" type="submit" onclick="audioUpload()">Display Audio</button>
<button type="submit" class="btn btn-outline-dark" onclick="addButton(times)">Display Times</button>
<button class="btn btn-outline-dark" type="reset" onclick="clearButtons()">Reset</button>
</div>
</div>
<div class="col">
<!--disply the audio bar, submit transcribes-->
<div class='urlsubmit'>
<form action="/transcribe" method="POST">
<input type="text" id="myText" placeholder="Some text...">
<input type="submit" value="cmd-f" class="btn btn-outline-dark">
</form>
</div>
<div >
<p id = 'keyval'></p>
</div>
<!--this is where the buttons appear-->
<div id='buttons'>
</div>
</div>
</div>
<div class="footer"><p>Created by Thai, Maggie, Brooke and Allison</p>
<p>cmd-f Hackathon Vancouver, March 9-10, 2019</p></div>
<script>
function playTimestamp(time) {
var myAudio=document.getElementById("sound");
myAudio.currentTime = time;
myAudio.play();
}
var times = [1, 20, 32, 51];
function addButton(times) {
document.getElementById("buttons").innerHTML = "";
times.forEach( function (t) {
var button= document.createElement('button');
button.type = "button";
button.appendChild(document.createTextNode(secondsminutes(t)));
button.setAttribute("onclick", "playTimestamp("+t+")");
document.getElementById("buttons").appendChild(button);
button.classList.add("buttonStyling");
button.classList.add("btn");
button.classList.add("btn-outline-dark");
});
// audioUpload();
document.getElementById("keyval").innerHTML=document.getElementById("myText").value + ' is located in the following times';
}
function secondsminutes(t) {
var seconds = t % 60;
var minutes = Math.floor(t/60);
var hours = Math.floor(minutes/60);
minutes = minutes % 60;
var strSec = seconds;
var strMin = minutes;
var strHours = hours;
if (hours.toString().length === 1) {
strHours = "0" + hours.toString();
}
if (minutes.toString().length === 1) {
strMin = "0" + minutes.toString();
}
if (seconds.toString().length === 1) {
strSec = "0" + seconds.toString();
}
var display = strHours + ":" + strMin + ":" + strSec;
return display;
}
function clearButtons() {
document.getElementById("buttons").innerHTML = "";
document.getElementById("sound").setAttribute("currentTime", 0);
}
function audioUpload() {
var audio = document.getElementById("upload").files[0];
var reader = new FileReader();
reader.onload = function(e) {
document.getElementById("sound").src = e.target.result;
document.getElementById("sound").controls = "controls";
}
reader.readAsDataURL(audio);
}
</script>
</body>
</html>