-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
executable file
·278 lines (266 loc) · 15.3 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
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
<!DOCTYPE html>
<!--
Copyright 2013 dc-square GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@author: Christoph Schäbel
Modified in 2018 for usage as Snips Test tool by
@author: Philipp Dürr
-->
<!--[if IE 8]>
<html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Snips - Web Test</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body class="notconnected">
<div id="header">
<div id="hcontent">
<img
src="https://forum.snips.ai/uploads/snips1/original/1X/16b983794c3a05685a582972b53ec8021e0c4c50.svg"
alt="Snips Community" id="site-logo" class="logo-big">
<div id="toplinkline">
<a class="toplink" href="https://forum.snips.ai/t/webtest-test-your-assistant-on-a-local-website-without-talking/801" target="_blank">
<svg width="18" height="18" viewBox="0 0 20 21" id="forum-outline" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M7.201 11.67v-.014zm.118-.482c.333-.397 1.349-.797 2.702-.797 1.354 0 2.37.4 2.703.797H7.319z" stroke="currentColor" stroke-width="2"></path><path d="M3 1h14a2 2 0 0 1 2 2v10.918a2 2 0 0 1-2 2H5.34a1 1 0 0 0-.657.246l-3.352 2.92a.2.2 0 0 1-.331-.15V3a2 2 0 0 1 2-2z" stroke="currentColor" stroke-width="2"></path><path d="M10.021 4.73c1.082 0 1.91.808 1.91 1.864s-.828 1.865-1.91 1.865c-1.081 0-1.91-.809-1.91-1.865s.829-1.865 1.91-1.865z" fill="currentColor"></path></g></svg>
Forum
</a>
<a class="toplink" onclick="toggleReadme();">
<svg width="18" height="18" viewBox="0 0 18 18" id="book" xmlns="http://www.w3.org/2000/svg"><path d="M1 2h4.8A3.2 3.2 0 0 1 9 5.2v11.2A2.4 2.4 0 0 0 6.6 14H1V2zm16 0h-4.8A3.2 3.2 0 0 0 9 5.2v11.2a2.4 2.4 0 0 1 2.4-2.4H17V2z" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg>
Readme
</a>
</div>
<h1>Web Test</h1>
<a onclick="toggleConnection()">
<div id="connectionStatus"></div>
</a>
</div>
</div>
<div class="headspace"></div>
<noscript>
<style type="text/css">
#body {display:none;}
</style>
<p>
You have JavaScript disabled. This tool is useless without JavaScript. Please enable it!
</p>
</noscript>
<div id="body">
<form class="connectCont" id="connectionMain">
<div class="rowInp">
<label>Host *</label>
<input id="urlInput" type="text" value="broker.mqttdashboard.com">
</div>
<div class="rowInp">
<label>Port *</label>
<input id="portInput" type="text" value="8000" />
</div>
<div class="rowInp">
<label>ClientID *</label>
<input id="clientIdInput" type="text" />
</div>
<div class="rowInp">
<label>Username</label>
<input id="userInput" type="text" />
</div>
<div class="rowInp">
<label>Password</label>
<input id="pwInput" type="password" />
</div>
<div class="rowInp">
<label>Keep Alive</label>
<input id="keepAliveInput" type="text" value="60" />
</div>
<div class="rowInp">
<label>SSL</label>
<input id="sslInput" type="checkbox" />
</div>
<div class="row">
<a id="connectButton" class="small button" onclick="websocketclient.connect();">Connect</a>
</div>
<div class="row">
<a id="disconnectButton" class="small button" onclick="websocketclient.disconnect();">Disconnect</a>
</div>
</form>
<div class="empty"></div>
<div id="contentMain">
<form>
<div class="row">
<div class="setup">
<div class="rowInp"><label>SiteId</label> <input id="siteId" type="text" value="test"></div>
<div class="rowInp"><label>Wakeword</label> <input id="wakeword" type="text" value="default"></div>
<div class="rowInp"><label>Language</label> <input id="ttsLang" type="text" value="de"></div>
<div class="rowInp"><label>SessionId</label> <input class="grayed" id="sessionId" type="text" value=""></div>
</div>
<!--- Test intent --->
<div class="large-2 columns">
<a class="button" id="testBut" onclick="testIntent()"> <svg
xmlns="http://www.w3.org/2000/svg" width="48" height="48"
viewBox="0 0 24 24">
<path fill="currentColor"
d="M12 1c-6.338 0-12 4.226-12 10.007 0 2.05.738 4.063 2.047 5.625.055 1.83-1.023 4.456-1.993 6.368 2.602-.47 6.301-1.508 7.978-2.536 9.236 2.247 15.968-3.405 15.968-9.457 0-5.812-5.701-10.007-12-10.007zm0 15c-.565 0-1.024-.459-1.024-1.025 0-.565.459-1.024 1.024-1.024.566 0 1.024.459 1.024 1.024 0 .566-.458 1.025-1.024 1.025zm1.606-4.858c-.74.799-.775 1.241-.766 1.785h-1.643c-.006-1.208.016-1.742 1.173-2.842.469-.446.84-.799.788-1.493-.047-.66-.599-1.004-1.117-1.004-.581 0-1.261.432-1.261 1.649h-1.646c0-1.966 1.155-3.237 2.941-3.237.849 0 1.592.278 2.09.783.468.473.709 1.125.7 1.883-.013 1.134-.704 1.878-1.259 2.476z" /></svg>
<br />Test<br /> Intent
</a>
</div>
<!--- Test TTS --->
<div class="large-2 columns">
<a class="button" id="testBut" onclick="testTTS()"> <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path d="M6 7l8-5v20l-8-5v-10zm-6 10h4v-10h-4v10zm20.264-13.264l-1.497 1.497c1.847 1.783 2.983 4.157 2.983 6.767 0 2.61-1.135 4.984-2.983 6.766l1.498 1.498c2.305-2.153 3.735-5.055 3.735-8.264s-1.43-6.11-3.736-8.264zm-.489 8.264c0-2.084-.915-3.967-2.384-5.391l-1.503 1.503c1.011 1.049 1.637 2.401 1.637 3.888 0 1.488-.623 2.841-1.634 3.891l1.503 1.503c1.468-1.424 2.381-3.309 2.381-5.394z"/></svg>
<br />Test<br /> TTS
</a>
</div>
<!-- hermes/asr/textCaptured -->
<div class="large-2 columns">
<a class="button" id="speakButMain" onclick="pretendInput()"> <svg
xmlns="http://www.w3.org/2000/svg" width="48" height="48"
viewBox="0 0 24 24">
<path fill="currentColor"
d="M12 1c-6.338 0-12 4.226-12 10.007 0 2.05.739 4.063 2.047 5.625.055 1.83-1.023 4.456-1.993 6.368 2.602-.47 6.301-1.508 7.978-2.536 9.236 2.247 15.968-3.405 15.968-9.457 0-5.812-5.701-10.007-12-10.007zm-5 11.5c-.829 0-1.5-.671-1.5-1.5s.671-1.5 1.5-1.5 1.5.671 1.5 1.5-.671 1.5-1.5 1.5zm5 0c-.829 0-1.5-.671-1.5-1.5s.671-1.5 1.5-1.5 1.5.671 1.5 1.5-.671 1.5-1.5 1.5zm5 0c-.828 0-1.5-.671-1.5-1.5s.672-1.5 1.5-1.5c.829 0 1.5.671 1.5 1.5s-.671 1.5-1.5 1.5z" /></svg>
<br />Simulate<br />Input
</a>
</div>
<!--- Wakeword detected --->
<div class="large-2 columns">
<a class="button" id="wakeButMain" onclick="wakeWord()"> <svg
xmlns="http://www.w3.org/2000/svg" width="48" height="48"
viewBox="0 0 24 24">
<path
d="M15.137 3.945c-.644-.374-1.042-1.07-1.041-1.82v-.003c.001-1.172-.938-2.122-2.096-2.122s-2.097.95-2.097 2.122v.003c.001.751-.396 1.446-1.041 1.82-4.667 2.712-1.985 11.715-6.862 13.306v1.749h20v-1.749c-4.877-1.591-2.195-10.594-6.863-13.306zm-3.137-2.945c.552 0 1 .449 1 1 0 .552-.448 1-1 1s-1-.448-1-1c0-.551.448-1 1-1zm3 20c0 1.598-1.392 3-2.971 3s-3.029-1.402-3.029-3h6z" />
<path class="onlymouseover"
d="M15 20m5.778-11.679c.18.721.05 1.446-.304 2.035l.97.584c.504-.838.688-1.869.433-2.892-.255-1.024-.9-1.848-1.739-2.351l-.582.97c.589.355 1.043.934 1.222 1.654zm.396-4.346l-.597.995c1.023.616 1.812 1.623 2.125 2.874.311 1.251.085 2.51-.53 3.534l.994.598c.536-.892.835-1.926.835-3-.001-1.98-1.01-3.909-2.827-5.001zm-16.73 2.692l-.582-.97c-.839.504-1.484 1.327-1.739 2.351-.255 1.023-.071 2.053.433 2.892l.97-.584c-.354-.588-.484-1.314-.304-2.035.179-.72.633-1.299 1.222-1.654zm-4.444 2.308c0 1.074.299 2.108.835 3l.994-.598c-.615-1.024-.841-2.283-.53-3.534.312-1.251 1.101-2.258 2.124-2.873l-.597-.995c-1.817 1.092-2.826 3.021-2.826 5z" /></svg>
<br />Simulate<br />Wakeword
</a>
</div>
</div>
<div class="row">
<label>Message</label>
<textarea id="publishPayload"></textarea>
</div>
</form>
<div class="row">
<label>Last TTS</label>
<div id="lastTTS"></div>
</div>
<div class="empty"></div><a class="button" style="width:64px;"onclick="websocketclient.render.clearMessages();">MQTT<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="M3 6v18h18v-18h-18zm5 14c0 .552-.448 1-1 1s-1-.448-1-1v-10c0-.552.448-1 1-1s1 .448 1 1v10zm5 0c0 .552-.448 1-1 1s-1-.448-1-1v-10c0-.552.448-1 1-1s1 .448 1 1v10zm5 0c0 .552-.448 1-1 1s-1-.448-1-1v-10c0-.552.448-1 1-1s1 .448 1 1v10zm4-18v2h-20v-2h5.711c.9 0 1.631-1.099 1.631-2h5.315c0 .901.73 2 1.631 2h5.712z"/></svg></a>
<div class="messagesTop">
<h3>MQTT Messages</h3>
</div>
<div class="row panel">
<div class="row">
<ul id="messEdit" class="disc">
</ul>
</div>
</div>
</div>
<div id="readmeMain">
<b>Requirements:</b>
<p>
This tool only works with JavaScript enabled and requires a MQTT Broker with websockets enabled.<br/>
For now websockets are not enabled by default in the snips MQTT Broker.<br/>
The only tested browser is Google Chrome - Please send feedback for any other browser!<br/>
</p><p>
<b>Connection and Settings:</b></p><p>
You can see your connection status in the top right corner (white chain/red broken chain).
By clicking on it you can connect, disconnect or change your connection settings.<br/>
You can save your settings in the provided "config.js" file. Then you will be connected to the MQTT broker right at the start of this page and your siteId etc. will be prefilled.<br/>
Currently your connection status is: <div><a onclick="toggleConnection()" style="background-color:#001EFF;padding: 5px;width: 28px;display: block;height: 28px;">
<div id="connectionStatus" style="float: none;margin: 2px;"></div>
</a></div>
</p><p>
<b>When you are connected, you can send out various messages to your Snips server.</b><br/>
</p>
<p>
Anytime you can send:
<ul><li><b>Test Intent</b>: Test an input(message field) and just see what intent would be found</li>
<li><b>Test TTS</b>: Send any message provided in the message field to the given SiteId (default, kitchen..) and listen to the text output. The language field will be required for this.</li>
<li><b>Simulate Wakeword</b>: Start a Dialogue by sending a wakeword to your current SiteId. This requires a filled "Wakeword" field.</li>
</ul>
</p><p>
After you send out a Wakeword and the field "Session ID" is filled, you can:<br/>
<ul><li><b>Simulate Input</b>: Send any text to snips, just like when it was captured by the ASR. This supports complex dialogues and will even ask for missing slots.
</li>
</ul>
After a session ended either by the expected end of the conversation, or by any error/timeout, you have to re-send a wakeword detected, if you want to send another message.
</p>
<p>
<b>About:</b><br/>
<p>
This is a completely private work.
It has only been released for public availability to help others that might find them selfes in the same situation as I did:<br/>
<p>"Hey Snips" ... "Hey Snips" ... "Hey Snips" ... "Hey S..." - "Honey, I want to listen to that TV show, could you go to your office?"</p><p>
So feel free to use it for what ever you like (but don't make more money with it than I do) and please respect the following sources I used.
</p>
<b>Thanks to:</b>
<p>Base code for MQTT handling by dc-square GmbH, Christoph Schäbel under Apache License, Version 2.0 - a general websocket MQTT client can be found at <a href="http://www.hivemq.com/demos/websocket-client/">hivemq.com</a>
</p>
<p>Icons by <a href=https://iconmonstr.com><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16.5 2.75c-.965 0-1.75.785-1.75 1.75s.785 1.75 1.75 1.75 1.75-.785 1.75-1.75-.785-1.75-1.75-1.75zm0-2.75c2.481 0 4.5 2.019 4.5 4.5s-2.019 4.5-4.5 4.5-4.5-2.019-4.5-4.5 2.019-4.5 4.5-4.5zm-5.5 17.01s2.539 3.087 4.022 4.944c1.163 1.454 2.025 2.046 3.462 2.046 1.411 0 2.516-1.065 2.516-2.309 0-.539-.183-1.111-.594-1.646-1.52-1.973-2.406-3.035-2.406-3.035h-7zm-3.136-.01h-2.864c-.551 0-1-.449-1-1s.449-1 1-1h13.279c.893 0 1.4.248 1.963.958.96 1.211 2.505 3.163 2.562 3.251.736-.87 1.196-1.98 1.196-3.209 0-2.761-2.239-5-5-5h-14c-2.761 0-5 2.239-5 5s2.239 5 5 5h6.141c-1.144-1.405-3.277-4-3.277-4zm.05-12.5l2.086 2.086-1.414 1.414-2.086-2.086-2.086 2.086-1.414-1.414 2.086-2.086-2.086-2.086 1.414-1.414 2.086 2.086 2.086-2.086 1.414 1.414-2.086 2.086z"/></svg> iconmonstr.com</a>
</p><p><a href="https://snips.ai/">Snips</a> - you would not be here if you didn't know about it..</p><p>
And at last, myself: <a href="https://console.snips.ai/user/user_D6z31xQrX8lQ">Philipp</a><br/><br/>
For feedback please use the forum link in the top bar, or directly in <a href=https://github.com/philipp2310/snips-WebTest>Git</a>.
<br/><br/>
Still reading? Won in lottery? You must be looking for my Ethereum wallet: <a href="https://etherscan.io/address/0x8f059DB9C98e0e9D9F3eD129e599a862C29aD9d0">0x8f059DB9C98e0e9D9F3eD129e599a862C29aD9d0</a>
</p>
</div>
</p>
</div>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script
src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>
<!--<script
src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js"></script> -->
<script
src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.1.0/moment.min.js"></script>
<script src="js/mqttws31.js"></script>
<script src="js/encoder.js"></script>
<script src="js/app.js"></script>
<script src="config.js"></script>
<script>
function randomString(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(Math.floor(Math.random()
* possible.length));
return text;
}
function subPre() {
websocketclient.subscribe("hermes/hotword/#", 0, 8899);
websocketclient.subscribe("hermes/asr/#", 0, 8899);
websocketclient.subscribe("hermes/dialogueManager/#", 0, 8899);
websocketclient.subscribe("hermes/nlu/#", 0, 8899);
websocketclient.subscribe("hermes/intent/#", 0, 8899);
websocketclient.subscribe("hermes/tts/#", 0, 8899);
websocketclient.subscribe("hermes/audioServer/+/playBytes/#", 0, 8899);
websocketclient.subscribe("hermes/audioServer/+/playFinished", 0, 8899);
}
websocketclient.render.hide('speakBut')
//$(document).foundation();
$(document).ready(function() {
$('#urlInput').val(websocketserver);
$('#portInput').val(websocketport);
$('#wakeword').val(wakeword);
$('#ttsLang').val(ttsLang);
$('#siteId').val(siteId);
$('#clientIdInput').val(clientId);
websocketclient.connect();
});
$(window).load(function(){
$("#body").css('visibility', 'visible');
});
</script>
</body>
</html>