-
Notifications
You must be signed in to change notification settings - Fork 1
/
audio.html
43 lines (39 loc) · 1.72 KB
/
audio.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>@leftshiftone/convey</title>
<link rel="stylesheet" href="dist/convey-all.css">
<script src="dist/convey-aud.js"></script>
</head>
<body>
<div class="lto-gaia">
<div class="lto-content"></div>
<div class="lto-suggest"></div>
<div>
<textarea title="" class="lto-textbox"></textarea>
<button class="lto-invoker"></button>
<button id="lto-recorder">Record</button>
</div>
</div>
</body>
<script>
document.addEventListener('DOMContentLoaded', function () {
const renderer = new GaiaConvey.NoopRenderer();
const listener = new GaiaConvey.DefaultListener();
// for audio support VoiceBehaviour must be bound to the MQTT connection. VoiceBehaviour requires a dedicated button
// element to start/stop recording on mousedown/mouseup
const recordButton = document.getElementById("lto-recorder");
const voiceBehaviour = new GaiaConvey.VoiceBehaviour(recordButton);
let gaia = new GaiaConvey.Gaia(renderer, listener);
gaia.connect('ws://localhost:61616/mqtt', 'e198738a-5042-47a0-93f7-19329fc48a88')
.then(connection => {
voiceBehaviour.bind(connection);
connection.subscribe(GaiaConvey.ChannelType.CONTEXT, (payload) => console.log("Context: " + JSON.stringify(payload)));
connection.subscribe(GaiaConvey.ChannelType.NOTIFICATION, (payload) => console.log("Notification: " + JSON.stringify(payload)));
connection.subscribe(GaiaConvey.ChannelType.LOG, (message) => console.log(`log message: ${JSON.stringify(message)}`))
connection.reception();
});
});
</script>
</html>