Skip to content

Commit e99301e

Browse files
committed
fixes and improved test page
1 parent 52eebfb commit e99301e

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

src/modules/picovoice/porcupine-keywords/hey_google_wasm_19.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PorcupineKeywords.v19.Hey_Edison = new Uint8Array([
1+
PorcupineKeywords.v19.Hey_Google = new Uint8Array([
22
0x51, 0x1b, 0x34, 0x5a, 0x57, 0xf4, 0x23, 0x97, 0x1b, 0x7c, 0xf6, 0x1c,
33
0x1b, 0x88, 0x0b, 0xde, 0xfa, 0xa1, 0x73, 0xb0, 0x0e, 0xf7, 0x76, 0x44,
44
0x7d, 0x64, 0xee, 0xfa, 0x1f, 0xda, 0x16, 0xc7, 0x1a, 0x53, 0x7f, 0xcf,

src/modules/picovoice/porcupine-keywords/picovoice_wasm.ppn renamed to src/modules/picovoice/porcupine-keywords/picovoice_wasm_19.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PorcupineKeywords.v19.Picovoice = new Uint8Array([
12
0xf6, 0x73, 0x90, 0x32, 0x94, 0x86, 0xb4, 0xf3, 0xe5, 0x26, 0x9e, 0x20,
23
0x05, 0x80, 0xeb, 0xd6, 0x22, 0x65, 0x94, 0x00, 0xdd, 0x0e, 0x7c, 0x5a,
34
0x9e, 0xcd, 0xc3, 0xd4, 0x96, 0xae, 0xdb, 0x6d, 0x46, 0x39, 0x1e, 0x4e,
@@ -502,3 +503,4 @@
502503
0xf7, 0x47, 0x79, 0x9c, 0x87, 0x9f, 0xe0, 0x06, 0x7a, 0x31, 0xb8, 0x17,
503504
0x54, 0x4f, 0x81, 0x0c, 0xde, 0x1b, 0xb4, 0x68, 0x2c, 0x82, 0xef, 0x7a,
504505
0xd9, 0x1b, 0x88, 0x20, 0x6a, 0x7e, 0xa8, 0x74
506+
]);

src/modules/porcupine-wake-word-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function constructWorker(options) {
131131

132132
keywords = options.setup.keywords || ["Computer"];
133133
keywords.forEach(function(kw){
134-
importScripts('./picovoice/porcupine-keywords/' + kw.toLowerCase() + "_wasm_" + porcupineVersion + '.js');
134+
importScripts('./picovoice/porcupine-keywords/' + kw.replace(/\s+/, "_").toLowerCase() + "_wasm_" + porcupineVersion + '.js');
135135
});
136136
sensitivities = options.setup.sensitivities || [0.5];
137137

test.html

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ <h1>SEPIA Web Audio Processor</h1>
8989
</div>
9090
<div id="wakeWordWorkerControls" class="contorlGroup">
9191
<label><b>Wake-Word</b></label>
92-
<label>TBD - (Porcupine fixed values)</label>
92+
<label>Buffer-Size:</label><input disabled placeholder="same as input atm.">
93+
<label>Sensitivity:</label><input id="wakeWordSensitivity" class="small" type="number" value="0.7" max="1" min="0" step="0.1" placeholder="0=low, 1=high" onchange="setWakeWordSensitivity(+this.value);">
94+
<label>Porcupine Version:</label><select id="porcupineVersionSelect" onchange="setPorcupineVersion(+this.value);">
95+
<option value="14" selected>v1.4</option>
96+
<option value="19">v1.9</option>
97+
</select><div style="flex: 1 0 100%;"></div>
9398
<label>Gate:</label><div id="wakeWordGateState"></div><label></label>
9499
<label>Control:</label><button onclick="wakeWordSetGate('open');">Listen</button><button onclick="wakeWordSetGate('close');">Stop</button><label></label>
95100
</div>
@@ -152,6 +157,7 @@ <h1>SEPIA Web Audio Processor</h1>
152157
+ "Input Sample-Rate=" + info.inputSampleRate
153158
+ " - Source-Type=" + info.sourceInfo.type;
154159
console.log("onReady", info);
160+
if (doUseWakeWordWorker) showLogMessage("Available wake-words", window.porcupineWorker.settings.options.setup.keywords);
155161

156162
//for testing:
157163
if (!doUseWaveEncoder && rec.source.mediaStream) createMediaRecorder(rec.source.mediaStream, info.sourceInfo);
@@ -352,19 +358,19 @@ <h1>SEPIA Web Audio Processor</h1>
352358
name: 'porcupine-wake-word-worker',
353359
type: 'worker',
354360
preLoad: {
355-
wasmFile: 'src/modules/picovoice/porcupine-19.wasm'
361+
wasmFile: (porcupineVersion == 14? 'src/modules/picovoice/porcupine-14.wasm' : 'src/modules/picovoice/porcupine-19.wasm')
356362
},
357363
settings: {
358-
onmessage: console.log, //TODO: change
364+
onmessage: onWakeWordMessage,
359365
//sendToModules: (doUseWaveEncoder? [waveEncoderIndex] : []),
360366
options: {
361367
setup: {
362368
inputSampleRate: (doUseResampler? resamplerSampleRate : 0),
363369
inputSampleSize: resamplerBufferSize, //output bufferSize of previous module
364-
bufferSize: 1024, //TODO: change
365-
version: 19,
366-
keywords: ["Computer", "Jarvis"],
367-
sensitivities: [0.5, 0.5]
370+
bufferSize: resamplerBufferSize, //TODO: this has no effect yet
371+
version: porcupineVersion,
372+
keywords: (porcupineVersion == 14? ["Hey SEPIA"] : ["Computer", "Jarvis", "Picovoice"]),
373+
sensitivities: (porcupineVersion == 14? [0.7] : [0.7, 0.7, 0.7, 0.7])
368374
}
369375
}
370376
}
@@ -581,6 +587,12 @@ <h1>SEPIA Web Audio Processor</h1>
581587
}
582588
}
583589
}
590+
function onWakeWordMessage(msg){
591+
//console.log(msg);
592+
if (msg && msg.keyword){
593+
showLogMessage("Wake-word detected", msg.keyword);
594+
}
595+
}
584596
function setVoiceActivity(data){
585597
//console.log("vad", data);
586598
if (data.voiceActivity != undefined){
@@ -782,6 +794,16 @@ <h1>SEPIA Web Audio Processor</h1>
782794
var doUseWakeWordWorker = document.getElementById("useWakeWordWorker").checked;
783795
var wakeWordGate = document.getElementById('wakeWordGateState');
784796
var wakeWordGateOpen = false;
797+
var wakeWordSensitivity = +document.getElementById("wakeWordSensitivity").value;
798+
var porcupineVersion = +document.getElementById("porcupineVersionSelect").value;
799+
function setWakeWordSensitivity(sense){
800+
wakeWordSensitivity = sense;
801+
console.log("wakeWordSensitivity", wakeWordSensitivity);
802+
}
803+
function setPorcupineVersion(version){
804+
porcupineVersion = version;
805+
console.log("porcupineVersion", porcupineVersion);
806+
}
785807
function wakeWordSetGate(state){
786808
window.porcupineWorker.handle.sendToModule({gate: state});
787809
//wakeWordGate.textContent = state;

0 commit comments

Comments
 (0)