Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
70 lines (62 loc) · 2.28 KB
/
Copy pathindex.html
File metadata and controls
70 lines (62 loc) · 2.28 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>AmazonLex</title>
<meta name="author" content="">
<meta name="description" content="LZB Voice Bot Demo">
<meta name="keywords" content="LZB Voice Bot Demo Widget">
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16"/>
<link rel="stylesheet" href="style.css">
</head>
<body class="wrapper">
<div class="audio-control">
<p id="audio-control" class="white-circle">
<img src="lex.png">
<canvas class="visualizer"></canvas>
</p>
<p><span id="message"></span></p>
</div>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.48.0.min.js"></script>
<script src="./dist/aws-lex-audio.js" type="text/javascript"></script>
<script src="renderer.js" type="text/javascript"></script>
<script type="text/javascript">
var IdentityPoolId_1 = '<cognito pool id goes here>';
var waveform = window.Waveform();
var message = document.getElementById('message');
var config, conversation;
message.textContent = 'Passive';
document.getElementById('audio-control').onclick = function () {
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: IdentityPoolId_1
});
AWS.config.region = 'us-east-1';
config = {
lexConfig: {
botName: 'LaZBoyLexOne',
botAlias: 'LatestVersion',
userId: 'userId'
}
};
conversation = new LexAudio.conversation(config, function (state) {
message.textContent = state + '...';
if (state === 'Listening') {
waveform.prepCanvas();
}
if (state === 'Sending') {
waveform.clearCanvas();
}
}, function (data) {
console.log('Lex Response Data: ', data);
console.log('Transcript: ', data.inputTranscript, ", Response: ", data.message);
}, function (error) {
message.textContent = error;
}, function (timeDomain, bufferLength) {
waveform.visualizeAudioBuffer(timeDomain, bufferLength);
});
conversation.advanceConversation();
};
</script>
</body>
</html>