-
Notifications
You must be signed in to change notification settings - Fork 15
/
demo.html
204 lines (189 loc) · 5.13 KB
/
demo.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>WeBAD Demo</title>
<link rel="shortcut icon" href="#">
<style>
body {
font-size: 18px;
font-family: 'courier'; /*"Lucida Console", Courier, monospace;*/
background-color: black;
color: white;
}
button {
font-size: 18px;
font-family: 'courier';
color: white;
background-color: white /*#4CAF50; Green */
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
}
#start {
background-color: green
}
#startconsoledebug {
background-color: yellow
}
#stopconsoledebug {
background-color: orange
}
#microphonestatus, #audiostatus, #recording {
font-size: 36px;
font-family: 'courier';
background-color: black;
color: white;
}
td, th {
border: 1px solid;
text-align: left;
padding: 10px;
}
</style>
</head>
<body>
<h1>WeBAD Demo</h1>
<h2>Web Browser Audio Detection/Speech Recording Events API</h2>
<div>
This sample shows how to implement an audio/speech detection in the browser, using a ScriptProcessor (Web Audio API).<br>
Github repo: <a href="https://github.com/solyarisoftware/webad">https://github.com/solyarisoftware/webad</a><br>
<br>
To open/close the console: CTRL-SHIFT-J on Chrome, or CTRL-SHIFT-K on Firefox.
</div>
<br>
<button id="start">START (required on Chrome)</button>
<button id="startconsoledebug">enable console logs</button>
<button id="stopconsoledebug">disable console logs</button>
<br>
<br>
<div>
REAL-TIME EVENTS/STATUS
<table>
<tr>
<th>Status</th>
<th>Value</th>
</tr>
<tr>
<td>microphone</td>
<td id="microphonestatuscell"><a id="microphonestatus"></a></td>
</tr>
<tr>
<td>audio</td>
<td id="audiostatuscell"><a id="audiostatus"></a></td>
</tr>
<tr>
<td>speech<br>recording</td>
<td id="recordingcell"><a id="recording"></a><p><audio id="audio" controls></audio></p></td>
</tr>
</table>
</div>
<br>
<div>
CONFIGURATION PARAMETERS
<table>
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
<tr>
<td>SAMPLE_POLLING_MSECS</td>
<td><a id="SAMPLE_POLLING_MSECS"></a></td>
</tr>
<tr>
<td>MAX_INTERSPEECH_SILENCE_MSECS</td>
<td><a id="MAX_INTERSPEECH_SILENCE_MSECS"></a></td>
</tr>
<tr>
<td>MIN_SIGNAL_DURATION</td>
<td><a id="MIN_SIGNAL_DURATION"></a></td>
</tr>
<tr>
<td>VOLUME_SIGNAL</td>
<td><a id="VOLUME_SIGNAL"></a></td>
</tr>
<tr>
<td>VOLUME_SILENCE</td>
<td><a id="VOLUME_SILENCE"></a></td>
</tr>
<tr>
<td>VOLUME_MUTE</td>
<td><a id="VOLUME_MUTE"></a></td>
</tr>
<tr>
<td>MIN_AVERAGE_SIGNAL_VOLUME</td>
<td><a id="MIN_AVERAGE_SIGNAL_VOLUME"></a></td>
</tr>
</table>
</div>
<br>
<div>
EVENTS EMITTED
<table>
<tr>
<th>Event name</th>
<th>Category</th>
<th>Description</th>
</tr>
<tr>
<td>signal</td>
<td>audio sample</td>
<td>volume is high, so probably user is speaking</td>
</tr>
<tr>
<td>silence</td>
<td>audio sample</td>
<td>volume is pretty low, the mic is on but there is not speech</td>
</tr>
<tr>
<td>mute</td>
<td>audio sample</td>
<td>volume is almost zero, the mic is off</td>
</tr>
<tr>
<td>unmutedmic</td>
<td>microphone</td>
<td>micro is UNMUTED (passing from OFF to ON)</td>
</tr>
<tr>
<td>mutedmic</td>
<td>microphone</td>
<td>micro is MUTED (passing from ON to OFF)</td>
</tr>
<tr>
<td>prespeechstart</td>
<td>recording</td>
<td>speech recording start</td>
</tr>
<tr>
<td>speechstart</td>
<td>recording</td>
<td>speech initial chunk start</td>
</tr>
<tr>
<td>speechstop</td>
<td>recording</td>
<td>speech recording stop</td>
</tr>
<tr>
<td>speechabort</td>
<td>recording</td>
<td>speech recording aborted</td>
</tr>
</table>
</div>
<!--
<canvas id="meter" width="500" height="50"></canvas>
-->
<script src="volume-meter.js"></script>
<script src="audioDetectionConfig.js"></script>
<script src="audioDetection.js"></script>
<script src="audioStream.js"></script>
<script src="demoAudioRecorder.js"></script>
<script src="demoAudioDetectionListeners.js"></script>
<script src="demo.js"></script>
</body>
</html>