Skip to content

Commit

Permalink
Attempting a sound
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonjesus committed Oct 17, 2017
1 parent 1d761d5 commit 54ccde1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const record = require('node-record-lpcm16');
const Detector = require('snowboy').Detector;
const Models = require('snowboy').Models;
const fs = require('fs');
const wav = require('wav');
const Speaker = require('speaker');

const models = new Models();

Expand Down Expand Up @@ -37,6 +40,19 @@ detector.on('hotword', function (index, hotword, buffer) {
// data after the hotword.
//console.log(buffer);
console.log('hotword', index, hotword);

var file = fs.createReadStream('listening.wav');
var reader = new wav.Reader();

// the "format" event gets emitted at the end of the WAVE header
reader.on('format', function (format) {

// the WAVE header is stripped from the output of the reader
reader.pipe(new Speaker(format));
});

// pipe the WAVE file to the Reader instance
file.pipe(reader);
});

const mic = record.start({
Expand Down
Binary file added listening.wav
Binary file not shown.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
"bugs": {
"url": "https://github.com/undocumented-code/CalvinAI/issues"
},
"homepage": "https://github.com/undocumented-code/CalvinAI#readme"
"homepage": "https://github.com/undocumented-code/CalvinAI#readme",
"dependencies": {
"snowboy": "latest",
"node-record-lpcm16": "latest",
"wav": "latest",
"speaker": "latest"
}
}

0 comments on commit 54ccde1

Please sign in to comment.