-
Notifications
You must be signed in to change notification settings - Fork 0
/
wakeword.html
154 lines (151 loc) · 7.7 KB
/
wakeword.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
<!--
Copyright 2021, Johannes Kropf
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.
-->
<script type="text/javascript">
RED.nodes.registerType('wake-word',{
category: 'wake-word',
color: '#E1A6AD',
defaults: {
wakeword: {value:"", type:"wakeword-config"},
threshold: {value: 0.5},
averaging: {value:true},
inputProp: {value:"payload"},
outputProp: {value:"payload"},
controlProp: {value:"control"},
passthrough: {value:false},
name: {value:""}
},
inputs:1,
outputs:2,
icon: "font-awesome/fa-bullhorn",
inputLabels: function(index) {
return "a stream of audio buffers / control msg's";
},
outputLabels: function(index) {
if (index === 0) {
return "wake-word detected"
} else {
return "forwarded audio buffers";
}
},
label: function() {
return this.name||"wakeword";
},
oneditprepare: function() {
var node = this;
$("#node-input-inputProp").typedInput({
type:"msg",
types:["msg"]
});
$("#node-input-outputProp").typedInput({
type:"msg",
types:["msg"]
});
$("#node-input-controlProp").typedInput({
type:"msg",
types:["msg"]
});
$("#node-input-threshold").on("change", function(){
let value = $("#node-input-threshold").val();
$("#thresholdValue").text(value);
});
}
});
</script>
<script type="text/html" data-template-name="wake-word">
<h4>Wake-Word</h4>
<div class="form-row">
<label for="node-input-wakeword"><i class="fa fa-commenting-o"></i> Wakeword</label>
<input type="text" id="node-input-wakeword">
</div>
<h4>Wake-Word Settings</h4>
<div class="form-row">
<label for="node-input-threshold"><i class="fa fa-signal"></i> Threshold</label>
<input type="range" min="0" max="1" step="0.01" id="node-input-threshold" style="width: 70%;">
<label for="node-input-threshold" id="thresholdValue" style="text-align:center;"></label>
</div>
<div class="form-row">
<label for="node-input-averaging"><i class="fa fa-sort-amount-asc"></i> Averaging</label>
<input type="checkbox" id="node-input-averaging" style="display:inline-block; width: auto; vertical-align:baseline;" value="true">
<label for="node-input-averaging" style="width: 70%;">enable template averaging</label>
</div>
<div class="form-row">
<label for="node-input-passthrough"><i class="fa fa-mail-forward"></i> Passthrough</label>
<input type="checkbox" id="node-input-passthrough" style="display:inline-block; width: auto; vertical-align:baseline;" value="false">
<label for="node-input-passthrough" style="width: 70%;">forward audio on detection event</label>
</div>
<h4>Input/Output Settings</h4>
<div class="form-row">
<label for="node-input-inputProp"><i class="fa fa-sign-in"></i> Input Field</label>
<input type="text" id="node-input-inputProp">
</div>
<div class="form-row">
<label for="node-input-outputProp"><i class="fa fa-sign-out"></i> Output Field</label>
<input type="text" id="node-input-outputProp">
</div>
<div class="form-row">
<label for="node-input-controlProp"><i class="fa fa-cogs"></i> Control Field</label>
<input type="text" id="node-input-controlProp">
</div>
<h4>Other Settings</h4>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="wake-word">
<p><strong>A node that listens to a stream of raw audio buffers to detect a wakeword
based on audio samples provided using the
<a href="https://github.com/mathquis/node-personal-wakeword">node-personal-wakeword</a> module.
</strong><br/></p>
<p><strong>Usage:</strong><br/>
This node will listen to a stream of raw audio buffers send to its configured input
to detect a wake-word configured in its configuration node.
The stream needs to have a certain format:<br/>
<i>Raw audio, little endian, signed-integer, mono, 16000 Hz, 16 bit.</i><br/>
It will send a message to the first output in the configured <code>msg</code> property when a
wake word was detected. When the node receives a message of <strong>stop</strong> in the configured
control property of the input <code>msg</code> it will stop the wake word detection process.
If you dont stop the input stream of audio buffers the wait wake process will start again.
When the node receives a message of <strong>pause</strong> in the configured
control property of the input <code>msg</code> it will pause sending messages when a wake-word
was detected. When the node receives a message of <strong>forward</strong> in the configured
control property of the input <code>msg</code> it will forward the input audio to its second
output. When the node receives a message of <strong>stop_forward</strong> in the configured
control property of the input <code>msg</code> it will stop forwarding the input audio to the
second output. When the node receives a message of <strong>stop_pause</strong> in the configured
control property of the input <code>msg</code> it will unpause if paused. The
<strong>listen</strong> command in the configured control property of the input <code>msg</code>
will do both unpause and also stop forwarding.<br/>
</p>
<p><strong>Configuration:</strong><br/>
You need to choose a configuration that the node will
use. The wake-word configuration will determin which audio files will be used to generate the
detector. You can than configure the threshold used to detect when listening. The higher the threshold
the lower the sensitivity but also less false positives will occur.
You can decide to activate or deactivate template averaging. Its activated by default.
With it deactivated the detector will need more resources but might have better detection
performance. There is also an optional
setting to automatically passthrough the stream of raw audio buffers when a wake word
was detected.
If this option is checked the node will automatically forward the audio stream on its second output
when a wake word was detected and ignore further detections. It will do so until
it receives a payload of <strong>listen</strong> or <strong>stop_forwarding</strong> on
its control <code>msg</code> property as per above. It will stop forwarding and/or go back to
listening after depending on the control message send. You can configure the input,
output and control properties of the <code>msg</code> object that the
node listens on and emits messages on.<br/></p>
<p><strong>Further Documentation:</strong><br/>
You can find the nodes repository
<a href="https://github.com/johanneskropf/node-red-contrib-personal-wake-word">here
</a>.</p>
</script>