├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── diagram.png ├── docs └── index.html ├── examples ├── node-knockknock │ ├── .gitignore │ ├── README.md │ ├── lib │ │ ├── knockknock-jokes.txt │ │ └── knockknock-logic.js │ ├── package-lock.json │ ├── package.json │ └── start.js ├── node-microphone │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ └── start.js ├── node-wakeword │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── sounds │ │ ├── bumblebee-off.wav │ │ ├── bumblebee-on.wav │ │ └── index.js │ └── start.js ├── not_working │ ├── electron-example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ │ ├── assets │ │ │ │ ├── logoTemplate.png │ │ │ │ └── logoTemplate@2x.png │ │ │ ├── bumblebee-workers │ │ │ │ ├── downsampling_worker.js │ │ │ │ ├── porcupine.js │ │ │ │ ├── porcupine_worker.js │ │ │ │ ├── pv_porcupine.js │ │ │ │ └── pv_porcupine.wasm │ │ │ ├── electron.js │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ ├── preload.js │ │ │ └── webworkers │ │ │ │ └── espeak-all-worker.js │ │ └── src │ │ │ ├── JaxcoreElectronApp.js │ │ │ ├── JaxcoreElectronApp.test.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ └── serviceWorker.js │ ├── extension-basic │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ └── robots.txt │ │ └── src │ │ │ ├── App.js │ │ │ ├── App.test.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ ├── serviceWorker.js │ │ │ └── setupTests.js │ ├── extension-voice-keyboard │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ └── robots.txt │ │ ├── src │ │ │ ├── App.js │ │ │ ├── index.css │ │ │ └── index.js │ │ └── yarn.lock │ ├── jaxcore-deepspeech-adapter │ │ ├── .gitignore │ │ ├── package.json │ │ └── start.js │ ├── kodi-control │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ └── start.js │ ├── mouse-control │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ └── start.js │ ├── number-typer │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── start.js │ │ └── test │ │ │ └── parser.test.js │ ├── web-basic-example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── public │ │ │ ├── bumblebee-workers │ │ │ │ ├── downsampling_worker.js │ │ │ │ ├── porcupine.js │ │ │ │ ├── porcupine_worker.js │ │ │ │ ├── pv_porcupine.js │ │ │ │ └── pv_porcupine.wasm │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ └── robots.txt │ │ ├── server.js │ │ ├── src │ │ │ ├── App.js │ │ │ ├── App.test.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ ├── serviceWorker.js │ │ │ └── setupTests.js │ │ └── yarn.lock │ └── web-hotword-example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── public │ │ ├── bumblebee-workers │ │ │ ├── downsampling_worker.js │ │ │ ├── porcupine.js │ │ │ ├── porcupine_worker.js │ │ │ ├── pv_porcupine.js │ │ │ └── pv_porcupine.wasm │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── manifest.json │ │ ├── sounds │ │ │ ├── bumblebee-off.mp3 │ │ │ └── bumblebee-on.mp3 │ │ └── webworkers │ │ │ └── espeak-en-worker.js │ │ ├── server.js │ │ ├── src │ │ ├── BumbleBeeDeepSpeechApp.js │ │ ├── index.css │ │ ├── index.js │ │ └── serviceWorker.js │ │ └── yarn.lock ├── old │ ├── node-hello-world │ │ └── start.js │ ├── node-microphone │ │ ├── continuous.js │ │ └── momentary.js │ ├── node-mouse-control │ │ ├── README.md │ │ └── start.js │ ├── node-speechadapter │ │ ├── .gitignore │ │ ├── package-lock.json │ │ ├── package.json │ │ └── start.js │ ├── node-voiceassistant │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ └── start.js │ ├── web-demo │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ └── manifest.json │ │ ├── src │ │ │ ├── ListenApp.js │ │ │ ├── ListenApp.test.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ └── serviceWorker.js │ │ └── yarn.lock │ └── web-vocab-tester │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── public │ │ ├── ding-end.wav │ │ ├── ding-start.wav │ │ ├── end.wav │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── manifest.json │ │ └── pv_porcupine.wasm │ │ ├── src │ │ ├── VocabApp.js │ │ ├── VocabApp.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── interpreters │ │ │ ├── ascii.js │ │ │ ├── ascii.json │ │ │ ├── chess.js │ │ │ ├── chess.json │ │ │ ├── datetime.js │ │ │ ├── datetime.json │ │ │ └── index.js │ │ └── serviceWorker.js │ │ └── yarn.lock └── voice-assistant-toolbox │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ └── start.js ├── index.js ├── lib ├── constants.js ├── deepspeech-process.js └── deepspeech-service.js ├── package-lock.json ├── package.json └── tools ├── ascii.csv ├── ascii.json ├── chess.csv ├── chess.json ├── datetime.csv ├── datetime.json ├── generate-ascii.js ├── generate-chess.js └── generate-substitutions.js /.gitignore: -------------------------------------------------------------------------------- 1 | deepspeech-0.* 2 | /deepspeech-* 3 | /deepspeech-*/* 4 | /models 5 | 6 | # dependencies 7 | /node_modules 8 | /*/node_modules 9 | /*/build 10 | /*/dist 11 | /.pnp 12 | .pnp.js 13 | 14 | # testing 15 | /coverage 16 | 17 | # production 18 | /build 19 | /www/build 20 | 21 | # misc 22 | .DS_Store 23 | .env.local 24 | .env.development.local 25 | .env.test.local 26 | .env.production.local 27 | 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .~lock* 32 | 33 | old-readme.md 34 | lib/old-speech.js 35 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Jaxcore Software Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS PROJECT IS NOW DEPRECATED 2 | 3 | The contents of `jaxcore-deepspeech-plugin` is being reformed into the 4 | Bumblebee Voice Application Server project which includes DeepSpeech support, 5 | hotword detection, and speech synthesis in one cohesive 6 | JavaScript voice API. 7 | 8 | [https://github.com/jaxcore/bumblebee](https://github.com/jaxcore/bumblebee) 9 | 10 | See the [old-README.md](old-README.md) -------------------------------------------------------------------------------- /diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/diagram.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/node-knockknock/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/node-knockknock/README.md: -------------------------------------------------------------------------------- 1 | # Knock, Knock Jokes Example 2 | 3 | This is a NodeJS example which create a Knock, Knock joke telling chatbot. 4 | 5 | --- 6 | 7 | ### Installation 8 | 9 | ``` 10 | git clone https://github.com/jaxcore/deepspeech-plugin 11 | cd deepspeech-plugin 12 | npm install 13 | ``` 14 | 15 | #### Download DeepSpeech Pre-Trained english model: 16 | 17 | If the DeepSpeech models have not previously been downloaded, do so now (beware this is a large download >1.8GB): 18 | 19 | ``` 20 | wget https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz 21 | tar xfvz deepspeech-0.6.0-models.tar.gz 22 | rm deepspeech-0.6.0-models.tar.gz 23 | ``` 24 | 25 | Go do the knock, knock example directory: 26 | 27 | ``` 28 | cd examples/node-knockknock 29 | ``` 30 | 31 | Install: 32 | 33 | ``` 34 | npm install 35 | npm install speaker 36 | ``` 37 | 38 | Mac OSX users will have to install an alternative speaker backend: 39 | 40 | ``` 41 | npm install speaker --mpg123-backend=openal --no-save 42 | ``` 43 | 44 | Start the server: 45 | 46 | ``` 47 | node start.js 48 | ``` 49 | 50 | #### Alternative deepspeech model directory 51 | 52 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 53 | 54 | ``` 55 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 56 | ``` 57 | 58 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/node-knockknock/lib/knockknock-jokes.txt: -------------------------------------------------------------------------------- 1 | Knock, knock! 2 | Who's there? 3 | Orange. 4 | Orange who? 5 | Orange you glad to see me? 6 | 7 | Knock, knock! 8 | Who's there? 9 | Dishes. 10 | Dishes who? 11 | Dishes the cops, open up! 12 | 13 | Knock, knock! 14 | Who's there? 15 | Doris. 16 | Doris who? 17 | Doris locked that's why I'm knocking. 18 | 19 | Knock, knock! 20 | Who's there? 21 | Harry. 22 | Harry who? 23 | Harry up it's cold outside! 24 | 25 | Knock, knock! 26 | Who's there? 27 | Boo. 28 | Boo who? 29 | Aww, don't cry – it's just a joke. 30 | 31 | Knock, knock! 32 | Who's there? 33 | Banana. 34 | Banana who? 35 | Knock knock 36 | Who's there? 37 | Banana. 38 | Banana who? 39 | Knock knock 40 | Who's there? 41 | Orange. 42 | Orange who? 43 | Orange you glad I didn't say banana? -------------------------------------------------------------------------------- /examples/node-knockknock/lib/knockknock-logic.js: -------------------------------------------------------------------------------- 1 | // load data file of knock, knock jokes 2 | const jokes = require('fs').readFileSync(__dirname+'/knockknock-jokes.txt', 'utf-8').split(/\n\n/).map(line => { 3 | return line.split(/\n/); 4 | }); 5 | 6 | let say, stopRecognition; 7 | function init(config) { 8 | say = config.say; 9 | stopRecognition = config.stopRecognition; 10 | } 11 | 12 | let jokeIndex = null; 13 | let lineIndex = null; 14 | let errorCount = 0; 15 | 16 | // deepspeech usually doesn't quite get these words right, so let's correct them using substitution 17 | const corrections = { 18 | 'banana': 'the nana who|the nana|by nana|but nana|but nanna', 19 | 'who\'s there': 'whose there|who is there|is there|who are|whose hair|who there', 20 | 'dishes who': 'dish is who|tish is who|this is who', 21 | 'who': 'whom', 22 | 'boo': 'bo|boom|booth', 23 | 'boo who': 'but who' 24 | }; 25 | 26 | function processSpeech(text, stats) { 27 | if (text === "exit") { 28 | sleep(); 29 | } 30 | else if (jokeIndex === null || isJokeDone()) { 31 | processMainMenuResponse(text); 32 | } 33 | else { 34 | processJokeResponse(text); 35 | } 36 | } 37 | 38 | function processMainMenuResponse(text) { 39 | console.log('Speech recognition result:', text); 40 | if (text === 'yes') { 41 | nextJoke(); 42 | } 43 | else if (text === 'no') { 44 | sleep(); 45 | } 46 | else { 47 | errorCount++; 48 | if (errorCount > 1) { 49 | say("I require a yes or no answer").then(intro); 50 | } 51 | } 52 | } 53 | 54 | function getLastLine() { 55 | return jokes[jokeIndex][lineIndex-1]; 56 | } 57 | function getExpectedResponse() { 58 | let expectedResponse; 59 | if (jokes[jokeIndex]) expectedResponse = jokes[jokeIndex][lineIndex]; 60 | expectedResponse = expectedResponse.toLowerCase().replace(/\?|\!/, '') 61 | return expectedResponse; 62 | } 63 | 64 | function makeCorrections(text, corrections) { 65 | // make corrections using string substitutions 66 | for (let key in corrections) { 67 | let r = '(?<=\\s|^)('+corrections[key]+')(?=\\s|$)'; 68 | let regex = new RegExp(r, 'i'); 69 | let match = regex.test(text); 70 | if (match) { 71 | text = text.replace(new RegExp(r, 'gi'), function (m, a) { 72 | console.log(m); 73 | return key; 74 | }); 75 | } 76 | } 77 | return text; 78 | } 79 | 80 | function processJokeResponse(text) { 81 | text = makeCorrections(text, corrections); 82 | 83 | let lastLine = getLastLine(); 84 | let expectedResponse = getExpectedResponse(); 85 | 86 | if (text === expectedResponse) { 87 | console.log('HUMAN Says:', text); 88 | nextLine(); 89 | } 90 | else { 91 | console.log('HUMAN Says:', '"'+text+'"'); 92 | console.log('Expected Response Was:', expectedResponse); 93 | errorCount++; 94 | let response; 95 | let repeatLine = false; 96 | switch (errorCount) { 97 | case 1: 98 | return; 99 | case 2: 100 | response = "Try again"; 101 | repeatLine = true; 102 | break; 103 | case 3: 104 | response = "You're supposed to say. " + expectedResponse; 105 | break; 106 | case 4: 107 | response = "You can stop at any time by saying ... exit"; 108 | errorCount = 0; 109 | repeatLine = true; 110 | break; 111 | } 112 | 113 | say(response).then(() => { 114 | if (repeatLine) { 115 | say(lastLine) 116 | } 117 | }) 118 | } 119 | } 120 | 121 | let jokeCount = 0; 122 | function nextJoke() { 123 | jokeCount++; 124 | if (jokeIndex === null) { 125 | jokeIndex = 0; 126 | } 127 | else jokeIndex++; 128 | lineIndex = null; 129 | nextLine(); 130 | } 131 | 132 | function nextLine() { 133 | errorCount = 0; 134 | 135 | if (isJokeDone()) { 136 | jokeDone(); 137 | } 138 | else { 139 | if (lineIndex === null) { 140 | lineIndex = 0; 141 | } 142 | else { 143 | lineIndex += 1; 144 | } 145 | 146 | if (isJokeDone()) { 147 | jokeDone(); 148 | return; 149 | } 150 | 151 | let isComputerLine = (lineIndex % 2 === 0); 152 | 153 | if (isComputerLine) { 154 | sayLine().then(() => { 155 | nextLine(); 156 | }); 157 | } 158 | } 159 | } 160 | 161 | function isJokeDone() { 162 | if (!jokes[jokeIndex]) return true; 163 | return jokeIndex !== null && lineIndex >= (jokes[jokeIndex].length); 164 | } 165 | 166 | function jokeDone() { 167 | say("Ha ha ha... I hope you liked that one").then(intro); 168 | } 169 | 170 | function sayLine() { 171 | let line = jokes[jokeIndex][lineIndex]; 172 | return say(line); 173 | } 174 | 175 | 176 | function sleep() { 177 | jokeIndex = null; 178 | lineIndex = null; 179 | stopRecognition(); 180 | } 181 | 182 | function intro() { 183 | return new Promise((resolve) => { 184 | if (jokeIndex === jokes.length - 1) { 185 | console.log('Returning to first joke'); 186 | jokeIndex = null; 187 | lineIndex = null; 188 | } 189 | 190 | let another = jokeCount === 0 ? 'a' : 'another'; 191 | say("Would you like to hear "+another+" knock knock joke?").then(() => { 192 | console.log('Say: YES or NO'); 193 | resolve(); 194 | }); 195 | }); 196 | } 197 | 198 | function begin() { 199 | nextJoke(); 200 | } 201 | 202 | module.exports = { 203 | init, 204 | processSpeech, 205 | intro, 206 | begin 207 | }; -------------------------------------------------------------------------------- /examples/node-knockknock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-wakeword-example", 3 | "version": "0.0.2", 4 | "description": "uses bumblebee as wake word to activate deepspeech", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.6", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "jaxcore-say-node": "0.0.6", 16 | "speaker": "^0.5.1", 17 | "wav": "^1.0.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/node-knockknock/start.js: -------------------------------------------------------------------------------- 1 | // load hotword detection 2 | const BumbleBee = require('bumblebee-hotword-node'); 3 | const bumblebee = new BumbleBee(); 4 | bumblebee.addHotword('bumblebee'); 5 | bumblebee.setHotword('bumblebee'); 6 | 7 | // load speech synthesis 8 | const Say = require('jaxcore-say-node'); 9 | Say.speaker = require('speaker'); 10 | const voice = new Say({language: 'en-us', profile: 'Jack'}); 11 | 12 | const jokeLogic = require('./lib/knockknock-logic.js'); 13 | 14 | // load speech recognition 15 | const DeepSpeech = require('jaxcore-deepspeech-plugin'); 16 | 17 | DeepSpeech.start({ 18 | modelName: 'english', 19 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model, 20 | silenceThreshold: 200, // how many milliseconds of silence before processing the audio 21 | vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 22 | debug: 'true' // show recording status 23 | }) 24 | .then(start) 25 | .catch(e => { 26 | console.error(e); 27 | }); 28 | 29 | let speechRecognitionActive = false; 30 | let speechSynthesisActive = false; 31 | let deepspeech = null; 32 | 33 | function start(deepspeechService) { 34 | deepspeech = deepspeechService; 35 | 36 | jokeLogic.init({ 37 | say, 38 | stopRecognition 39 | }); 40 | 41 | deepspeech.on('recognize', (text, stats) => { 42 | jokeLogic.processSpeech(text, stats); 43 | }); 44 | 45 | bumblebee.on('hotword', onHotword); 46 | 47 | bumblebee.on('data', function (data) { 48 | if (speechRecognitionActive && !speechSynthesisActive) { 49 | deepspeech.streamData(data); 50 | } 51 | else { 52 | process.stdout.write('_'); 53 | } 54 | }); 55 | 56 | bumblebee.on('muted', function () { 57 | process.stdout.write('~'); 58 | }); 59 | 60 | bumblebee.on('connect', function() { 61 | // enable both bumblebee and deepspeech on startup 62 | bumblebee.start(); 63 | speechRecognitionActive = true; 64 | // say the first joke 65 | jokeLogic.begin(); 66 | }); 67 | bumblebee.connect(); 68 | } 69 | 70 | function onHotword(hotword) { 71 | console.log('\nHotword Detected: ['+hotword+']'); 72 | if (speechRecognitionActive) { 73 | stopRecognition(); 74 | } 75 | else if (!speechRecognitionActive) { 76 | startRecognition(); 77 | } 78 | deepspeech.streamReset(); // reset to ignore speech recognition of the hotword that was spoken 79 | } 80 | 81 | function say(text) { 82 | return new Promise((resolve) => { 83 | console.log('\nCOMPUTER Says:', text); 84 | speechSynthesisActive = true; // disable deepspeech while using text-to-speech 85 | bumblebee.setMuted(true); // disable bumblebee while using text-to-speech 86 | voice.say(text).then(() => { 87 | // delay a bit and reset the deepspeech buffer before re-enabling recognition 88 | setTimeout(function () { 89 | bumblebee.setMuted(false); 90 | deepspeech.streamReset(); 91 | speechSynthesisActive = false; 92 | resolve(); 93 | }, 200); 94 | }); 95 | }); 96 | } 97 | 98 | function stopRecognition() { 99 | speechRecognitionActive = false; 100 | return say("Alright.").then(() => { 101 | say("To wake me up just say the magic word... bumble bee"); 102 | }); 103 | } 104 | 105 | function startRecognition() { 106 | return new Promise((resolve, reject) => { 107 | speechRecognitionActive = false; 108 | jokeLogic.intro().then(() => { 109 | speechRecognitionActive = true; 110 | resolve(); 111 | }); 112 | }); 113 | } 114 | -------------------------------------------------------------------------------- /examples/node-microphone/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/node-microphone/README.md: -------------------------------------------------------------------------------- 1 | This example runs entirely in NodeJS, and starts the system microphone for recording. 2 | 3 | ``` 4 | npm install 5 | ``` 6 | 7 | ``` 8 | node start.js 9 | ``` 10 | 11 | #### Alternative deepspeech model directory 12 | 13 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 14 | 15 | ``` 16 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 17 | ``` 18 | 19 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/node-microphone/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-microphone-example", 3 | "version": "0.0.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "audio-format": { 8 | "version": "2.3.2", 9 | "resolved": "https://registry.npmjs.org/audio-format/-/audio-format-2.3.2.tgz", 10 | "integrity": "sha512-5IA2grZhaVhpGxX6lbJm8VVh/SKQULMXXrFxuiodi0zhzDPRB8BJfieo89AclEQv4bDxZRH4lv06qNnxqkFhKQ==", 11 | "requires": { 12 | "is-audio-buffer": "^1.0.11", 13 | "is-buffer": "^1.1.5", 14 | "is-plain-obj": "^1.1.0", 15 | "pick-by-alias": "^1.2.0", 16 | "sample-rate": "^2.0.0" 17 | } 18 | }, 19 | "bumblebee-hotword-node": { 20 | "version": "0.0.6", 21 | "resolved": "https://registry.npmjs.org/bumblebee-hotword-node/-/bumblebee-hotword-node-0.0.6.tgz", 22 | "integrity": "sha512-x5UySZ2jGTctMoTQdE7UNYBbuA+dIT9RSUn65ZAgG9qrrpV+kjaA1KUjoZmZ9UWKenKym9/uHYNMWp36pPslgQ==", 23 | "requires": { 24 | "node-audiorecorder": "^1.4.2", 25 | "pcm-convert": "^1.6.5" 26 | } 27 | }, 28 | "is-audio-buffer": { 29 | "version": "1.1.0", 30 | "resolved": "https://registry.npmjs.org/is-audio-buffer/-/is-audio-buffer-1.1.0.tgz", 31 | "integrity": "sha512-fmPC/dizJmP4ITCsW5oTQGMJ9wZVE+A/zAe6FQo3XwgERxmXHmm3ON5XkWDAxmyxvsrDmWx3NArpSgamp/59AA==" 32 | }, 33 | "is-buffer": { 34 | "version": "1.1.6", 35 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", 36 | "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" 37 | }, 38 | "is-plain-obj": { 39 | "version": "1.1.0", 40 | "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", 41 | "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" 42 | }, 43 | "node-audiorecorder": { 44 | "version": "1.4.2", 45 | "resolved": "https://registry.npmjs.org/node-audiorecorder/-/node-audiorecorder-1.4.2.tgz", 46 | "integrity": "sha512-Yu6Tyzn6LaKjqXe0lI832OF9CnAEzrgfNz3ofL/zhoHcnAs2DXlDK8GifQTAEA1bA4mMciSsi8nvn8Jye6XCMQ==" 47 | }, 48 | "object-assign": { 49 | "version": "4.1.1", 50 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 51 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 52 | }, 53 | "pcm-convert": { 54 | "version": "1.6.5", 55 | "resolved": "https://registry.npmjs.org/pcm-convert/-/pcm-convert-1.6.5.tgz", 56 | "integrity": "sha512-5CEspU4j8aEQ80AhNbcLfpT0apc93E6endFxahWd4sV70I6PN7LPdz8GoYm/1qr400K9bUVsVA+KxNgbFROZPw==", 57 | "requires": { 58 | "audio-format": "^2.3.2", 59 | "is-audio-buffer": "^1.0.11", 60 | "is-buffer": "^1.1.5", 61 | "object-assign": "^4.1.1" 62 | } 63 | }, 64 | "pick-by-alias": { 65 | "version": "1.2.0", 66 | "resolved": "https://registry.npmjs.org/pick-by-alias/-/pick-by-alias-1.2.0.tgz", 67 | "integrity": "sha1-X3yysfIabh6ISgyHhVqko3NhEHs=" 68 | }, 69 | "sample-rate": { 70 | "version": "2.0.1", 71 | "resolved": "https://registry.npmjs.org/sample-rate/-/sample-rate-2.0.1.tgz", 72 | "integrity": "sha512-AIK0vVBiAEObmpJOxQu/WCyklnWGqzTSDII4O7nBo+SJHmfgBUiYhgV/Y3Ohz76gfSlU6R5CIAKggj+nAOLSvg==" 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /examples/node-microphone/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-microphone-example", 3 | "version": "0.0.1", 4 | "description": "uses bumblebee as wake word to activate deepspeech", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.6" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/node-microphone/start.js: -------------------------------------------------------------------------------- 1 | const DeepSpeechPlugin = require('jaxcore-deepspeech-plugin'); 2 | const BumbleBee = require('bumblebee-hotword-node'); 3 | 4 | const bumblebee = new BumbleBee(); 5 | bumblebee.addHotword('bumblebee'); 6 | bumblebee.setHotword('bumblebee'); 7 | 8 | DeepSpeechPlugin.start({ 9 | modelName: 'english', 10 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model, 11 | silenceThreshold: 200, // delay for this long before processing the audio 12 | vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 13 | debug: true 14 | }) 15 | .then(deepspeech => { 16 | // receive the speech recognition results 17 | deepspeech.on('recognize', (text, stats) => { 18 | console.log('\nrecognize:', text, stats); 19 | }); 20 | 21 | bumblebee.on('hotword', function (hotword) { 22 | console.log('Hotword Detected:', hotword); 23 | }); 24 | 25 | // bumblebee emits a "data" event for every 8192 bytes of audio it records from the microphone 26 | bumblebee.on('data', function(data) { 27 | // stream the data to the deepspeech plugin 28 | deepspeech.streamData(data); 29 | }); 30 | 31 | // bumblebee start the microphone 32 | bumblebee.start(); 33 | }) 34 | .catch(console.error); -------------------------------------------------------------------------------- /examples/node-wakeword/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/node-wakeword/README.md: -------------------------------------------------------------------------------- 1 | This NodeJS example uses [BumbleBee Hotword](https://github.com/jaxcore/bumblebee-hotword-node) to turn DeepSpeech on and off. 2 | 3 | ``` 4 | npm install 5 | ``` 6 | 7 | MacOSX users will need to install the alternative speaker module: Installing `speaker` with the optional parameters is necessary for the audio to play properly in Mac OSX. 8 | 9 | ``` 10 | npm install speaker --mpg123-backend=openal 11 | ``` 12 | 13 | ``` 14 | node start.js 15 | ``` 16 | 17 | #### Alternative deepspeech model directory 18 | 19 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 20 | 21 | ``` 22 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 23 | ``` 24 | 25 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) 26 | -------------------------------------------------------------------------------- /examples/node-wakeword/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-wakeword-example", 3 | "version": "0.0.1", 4 | "description": "uses bumblebee as wake word to activate deepspeech", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.6", 13 | "jaxcore": "0.0.2", 14 | "speaker": "^0.5.1", 15 | "wav": "^1.0.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/node-wakeword/sounds/bumblebee-off.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/node-wakeword/sounds/bumblebee-off.wav -------------------------------------------------------------------------------- /examples/node-wakeword/sounds/bumblebee-on.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/node-wakeword/sounds/bumblebee-on.wav -------------------------------------------------------------------------------- /examples/node-wakeword/sounds/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var wav = require('wav'); 3 | var Speaker = require('speaker'); 4 | 5 | function playOn() { 6 | playSound(__dirname + '/bumblebee-on.wav') 7 | } 8 | function playOff() { 9 | playSound(__dirname + '/bumblebee-off.wav') 10 | } 11 | function playSound(path) { 12 | var file = fs.createReadStream(path); 13 | var reader = new wav.Reader(); 14 | reader.on('format', function (format) { 15 | // the WAVE header is stripped from the output of the reader 16 | reader.pipe(new Speaker(format)); 17 | }); 18 | file.pipe(reader); 19 | } 20 | 21 | module.exports = { 22 | playOn, 23 | playOff, 24 | }; -------------------------------------------------------------------------------- /examples/node-wakeword/start.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const jaxcore = new Jaxcore(); 3 | // jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 4 | jaxcore.addPlugin(require('../../')); 5 | 6 | const BumbleBee = require('bumblebee-hotword-node'); 7 | const bumblebee = new BumbleBee(); 8 | bumblebee.addHotword('bumblebee'); 9 | 10 | const {playOn, playOff} = require('./sounds'); 11 | 12 | let speechRecognitionActive = false; 13 | 14 | jaxcore.startService('deepspeech', { 15 | modelName: 'english', 16 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model, 17 | silenceThreshold: 200, // how many milliseconds of silence before processing the audio 18 | vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 19 | debug: true 20 | }, function(err, deepspeech) { 21 | 22 | deepspeech.on('recognize', (text, stats) => { 23 | console.log('Speech Recognition Result:', text); 24 | }); 25 | 26 | bumblebee.on('hotword', function(hotword) { 27 | if (speechRecognitionActive) { 28 | console.log('\nSPEECH RECOGNITION OFF'); 29 | console.log('\nStart speech recognition by saying:', 'BUMBLEBEE'); 30 | playOff(); 31 | speechRecognitionActive = false; 32 | } 33 | else if (!speechRecognitionActive) { 34 | console.log('\nSPEECH RECOGNITION ON'); 35 | console.log('Stop speech recognition by saying:', 'BUMBLEBEE'); 36 | playOn(); 37 | speechRecognitionActive = true; 38 | } 39 | deepspeech.streamReset(); // reset deepspeech to ignore speech recognition of the hotword that was spoken 40 | }); 41 | 42 | bumblebee.on('data', function (intData, sampleRate, hotword, float32arr) { 43 | if (speechRecognitionActive) { 44 | deepspeech.dualStreamData(intData, float32arr, 16000); 45 | } 46 | }); 47 | 48 | bumblebee.start(); 49 | 50 | console.log('\nStart speech recognition by saying:', 'BUMBLEBEE'); 51 | }); -------------------------------------------------------------------------------- /examples/not_working/electron-example/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | public/jaxcore/deepspeech-* 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/README.md: -------------------------------------------------------------------------------- 1 | ### install and run development build 2 | 3 | ``` 4 | yarn 5 | yarn run rebuild 6 | yarn run dev 7 | ``` 8 | 9 | If you experience node version compliation problems try the following: 10 | 11 | ``` 12 | yarn cache clean 13 | yarn run rebuild 14 | ``` 15 | 16 | And then try `yarn run dev` again. -------------------------------------------------------------------------------- /examples/not_working/electron-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jaxcore-deepspeech-example", 3 | "version": "0.0.2", 4 | "private": true, 5 | "main": "public/electron.js", 6 | "dependencies": { 7 | "bumblebee-hotword": "0.0.6", 8 | "electron-is-dev": "^1.1.0", 9 | "jaxcore": "0.0.2", 10 | "jaxcore-deepspeech-plugin": "0.0.6", 11 | "lodash": "^4.17.15", 12 | "node-abi": "^2.12.0", 13 | "node-vad": "^1.1.4", 14 | "react": "^16.12.0", 15 | "react-dom": "^16.12.0", 16 | "react-scripts": "^3.3.0" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test", 22 | "eject": "react-scripts eject", 23 | "dev": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"", 24 | "rebuild": "npm rebuild --runtime=electron --target=9.0.2 --disturl=https://atom.io/download/atom-shell --abi=75" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | }, 41 | "devDependencies": { 42 | "concurrently": "^5.0.0", 43 | "electron": "^9.0.2", 44 | "electron-builder": "^22.7.0", 45 | "electron-rebuild": "^1.11.0", 46 | "wait-on": "^3.3.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/assets/logoTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/assets/logoTemplate.png -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/assets/logoTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/assets/logoTemplate@2x.png -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/bumblebee-workers/downsampling_worker.js: -------------------------------------------------------------------------------- 1 | onmessage = function (e) { 2 | switch (e.data.command) { 3 | case "init": 4 | init(e.data.inputSampleRate); 5 | break; 6 | case "process": 7 | process(e.data.inputFrame); 8 | break; 9 | case "reset": 10 | reset(); 11 | break; 12 | } 13 | }; 14 | 15 | let inputSampleRate; 16 | let inputBuffer = []; 17 | 18 | function init(x) { 19 | inputSampleRate = x; 20 | } 21 | 22 | function process(inputFrame) { 23 | for (let i = 0; i < inputFrame.length; i++) { 24 | inputBuffer.push((inputFrame[i]) * 32767); 25 | } 26 | 27 | const PV_SAMPLE_RATE = 16000; 28 | const PV_FRAME_LENGTH = 512; 29 | 30 | while ((inputBuffer.length * PV_SAMPLE_RATE / inputSampleRate) > PV_FRAME_LENGTH) { 31 | let outputFrame = new Int16Array(PV_FRAME_LENGTH); 32 | let sum = 0; 33 | let num = 0; 34 | let outputIndex = 0; 35 | let inputIndex = 0; 36 | 37 | while (outputIndex < PV_FRAME_LENGTH) { 38 | sum = 0; 39 | num = 0; 40 | while (inputIndex < Math.min(inputBuffer.length, (outputIndex + 1) * inputSampleRate / PV_SAMPLE_RATE)) { 41 | sum += inputBuffer[inputIndex]; 42 | num++; 43 | inputIndex++; 44 | } 45 | outputFrame[outputIndex] = sum / num; 46 | outputIndex++; 47 | } 48 | 49 | postMessage(outputFrame); 50 | 51 | inputBuffer = inputBuffer.slice(inputIndex); 52 | } 53 | } 54 | 55 | function reset() { 56 | inputBuffer = []; 57 | } -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/bumblebee-workers/porcupine.js: -------------------------------------------------------------------------------- 1 | let Porcupine = (function () { 2 | /** 3 | * Binding for wake word detection object. It initializes the JS binding for WebAssembly module and exposes 4 | * a factory method for creating new instances of wake word engine. 5 | */ 6 | 7 | let initWasm = null; 8 | let releaseWasm = null; 9 | let processWasm = null; 10 | let sampleRate = null; 11 | let frameLength = null; 12 | let version = null; 13 | 14 | let porcupineModule = PorcupineModule(); 15 | porcupineModule.then(function(Module) { 16 | initWasm = Module.cwrap('pv_porcupine_wasm_init', 'number', ['number', 'number', 'number', 'number']); 17 | releaseWasm = Module.cwrap('pv_porcupine_wasm_delete', ['number']); 18 | processWasm = Module.cwrap('pv_porcupine_wasm_process', 'number', ['number', 'number']); 19 | sampleRate = Module.cwrap('pv_wasm_sample_rate', 'number', [])(); 20 | frameLength = Module.cwrap('pv_porcupine_wasm_frame_length', 'number', [])(); 21 | version = Module.cwrap('pv_porcupine_wasm_version', 'string', [])(); 22 | }); 23 | 24 | let isLoaded = function() { 25 | /** 26 | * Flag indicating if 'PorcupineModule' is loaded. .create() can only be called after loading is finished. 27 | */ 28 | return initWasm != null; 29 | }; 30 | 31 | let create = function (keywordIDs, sensitivities) { 32 | /** 33 | * Creates an instance of wake word detection engine (aka porcupine). Can be called only after .isLoaded() 34 | * returns true. 35 | * @param {Array} Array of keyword IDs. A keyword ID is the signature for a given phrase to be detected. Each 36 | * keyword ID should be stored as UInt8Array. 37 | * @param {Float32Array} Detection sensitivity. A higher sensitivity reduces miss rate at the cost of higher 38 | * false alarm rate. Sensitivity is a number within [0, 1]. 39 | * @returns An instance of wake word detection engine. 40 | */ 41 | let keywordIDSizes = Int32Array.from(keywordIDs.map(keywordID => keywordID.byteLength)); 42 | let keywordIDSizesPointer = porcupineModule._malloc(keywordIDSizes.byteLength); 43 | let keywordIDSizesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, keywordIDSizesPointer, keywordIDSizes.byteLength); 44 | keywordIDSizesBuffer.set(new Uint8Array(keywordIDSizes.buffer)); 45 | 46 | let keywordIDPointers = Uint32Array.from(keywordIDs.map(keywordID => { 47 | let heapPointer = porcupineModule._malloc(keywordID.byteLength); 48 | let heapBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, heapPointer, keywordID.byteLength); 49 | heapBuffer.set(keywordID); 50 | return heapPointer; 51 | })); 52 | 53 | let keywordIDPointersPointer = porcupineModule._malloc(keywordIDPointers.byteLength); 54 | let keywordIDPointersBuffer = new Uint8Array( 55 | porcupineModule.HEAPU8.buffer, 56 | keywordIDPointersPointer, 57 | keywordIDPointers.byteLength); 58 | keywordIDPointersBuffer.set(new Uint8Array(keywordIDPointers.buffer)); 59 | 60 | let sensitivitiesPointer = porcupineModule._malloc(sensitivities.byteLength); 61 | let sensitivitiesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, sensitivitiesPointer, sensitivities.byteLength); 62 | sensitivitiesBuffer.set(new Uint8Array(sensitivities.buffer)); 63 | 64 | let handleWasm = initWasm( 65 | keywordIDs.length, 66 | keywordIDSizesPointer, 67 | keywordIDPointersPointer, 68 | sensitivitiesPointer); 69 | if (handleWasm === 0) { 70 | throw new Error("failed to initialize porcupine."); 71 | } 72 | 73 | let pcmWasmPointer = porcupineModule._malloc(frameLength * 2); 74 | 75 | let release = function () { 76 | /** 77 | * Releases resources acquired by WebAssembly module. 78 | */ 79 | 80 | releaseWasm(handleWasm); 81 | porcupineModule._free(pcmWasmPointer); 82 | }; 83 | 84 | let process = function (pcmInt16Array) { 85 | /** 86 | * Processes a frame of audio. The required sample rate can be retrieved from .sampleRate and the length of 87 | * frame (number of samples within frame) can be retrieved from .frameLength. 88 | * @param {Int16Array} A frame of audio with properties described above. 89 | * @returns {Number} Index of detected keyword (phrase). When no keyword is detected it returns -1. 90 | */ 91 | 92 | let pcmWasmBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, pcmWasmPointer, pcmInt16Array.byteLength); 93 | pcmWasmBuffer.set(new Uint8Array(pcmInt16Array.buffer)); 94 | 95 | let keyword_index = processWasm(handleWasm, pcmWasmPointer); 96 | if (keyword_index === -2) { 97 | throw new Error("porcupine failed to process audio"); 98 | } 99 | 100 | return keyword_index; 101 | }; 102 | 103 | return { 104 | release: release, 105 | process: process, 106 | sampleRate: sampleRate, 107 | frameLength: frameLength, 108 | version: version 109 | } 110 | }; 111 | 112 | return {isLoaded: isLoaded, create: create} 113 | })(); 114 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/bumblebee-workers/porcupine_worker.js: -------------------------------------------------------------------------------- 1 | importScripts("pv_porcupine.js"); 2 | importScripts("porcupine.js"); 3 | 4 | onmessage = function (e) { 5 | switch (e.data.command) { 6 | case "init": 7 | init(e.data.keywordIDs, e.data.sensitivities); 8 | break; 9 | case "process": 10 | process(e.data.inputFrame); 11 | break; 12 | case "release": 13 | release(); 14 | break; 15 | } 16 | }; 17 | 18 | let keywordIDArray; 19 | let keywords; 20 | let sensitivities; 21 | 22 | let porcupine = null; 23 | 24 | function init(keywordIDs, _sensitivities_) { 25 | keywordIDArray = Object.values(keywordIDs); 26 | keywords = Object.keys(keywordIDs); 27 | sensitivities = _sensitivities_; 28 | 29 | if (Porcupine.isLoaded()) { 30 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 31 | } 32 | } 33 | 34 | function process(inputFrame) { 35 | if (porcupine == null && Porcupine.isLoaded()) { 36 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 37 | } else if (porcupine != null) { 38 | let keywordIndex = porcupine.process(inputFrame); 39 | postMessage({keyword: keywordIndex === -1 ? null : keywords[keywordIndex]}); 40 | } 41 | } 42 | 43 | function release() { 44 | if (porcupine !== null) { 45 | porcupine.release(); 46 | } 47 | 48 | porcupine = null; 49 | } 50 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/bumblebee-workers/pv_porcupine.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/bumblebee-workers/pv_porcupine.wasm -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/electron.js: -------------------------------------------------------------------------------- 1 | // This project was based off of this electron/react tutorial: 2 | // https://www.codementor.io/randyfindley/how-to-build-an-electron-app-using-create-react-app-and-electron-builder-ss1k0sfer 3 | 4 | const electron = require('electron'); 5 | const app = electron.app; 6 | const BrowserWindow = electron.BrowserWindow; 7 | const ipcMain = electron.ipcMain; 8 | const path = require('path'); 9 | const isDev = require('electron-is-dev'); 10 | 11 | const Jaxcore = require('jaxcore'); 12 | const jaxcore = new Jaxcore(); 13 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 14 | 15 | if (isDev) process.env.NODE_ENV = 'dev'; 16 | 17 | let mainWindow; 18 | 19 | const executeJavaScript = (win, codeStr, callback) => { 20 | // BEWARE: 21 | // executing "codeStr" is potentially harmful 22 | // it is recommented to only call functions with parameters encoded as JSON using JSON.stringify() 23 | if (win.webContents && win.webContents.executeJavaScript) { 24 | try { 25 | win.webContents.executeJavaScript(codeStr).then((result) => { 26 | callback(result); 27 | }).catch((e) => { 28 | console.error('executeJavaScript', e); 29 | }); 30 | } catch (e) { 31 | console.error(e); 32 | process.exit(); 33 | } 34 | } 35 | else { 36 | console.error('no webContents'); 37 | process.exit(); 38 | } 39 | }; 40 | 41 | function createWindow() { 42 | mainWindow = new BrowserWindow({ 43 | width: 480, 44 | height: 640, 45 | webPreferences: { 46 | // allow code inside this window to use use native window.open() 47 | nativeWindowOpen: true, 48 | nodeIntegrationInWorker: true, 49 | preload: __dirname + '/preload.js' 50 | } 51 | }); 52 | 53 | mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`); 54 | 55 | if (isDev) { 56 | // Open the DevTools. 57 | // BrowserWindow.addDevToolsExtension(''); 58 | // mainWindow.webContents.openDevTools(); 59 | } 60 | 61 | mainWindow.on('closed', () => mainWindow = null); 62 | 63 | mainWindow.on('close', function (event) { 64 | console.log('close -> hide'); 65 | event.preventDefault(); 66 | mainWindow.hide(); 67 | }); 68 | 69 | ipcMain.on('client-ready', (event, arg) => { 70 | event.reply('electron-ready'); 71 | }); 72 | 73 | // start the jaxcore deepspeech service 74 | jaxcore.startService('deepspeech', { 75 | modelName: 'english', 76 | modelPath: __dirname + '/../../../deepspeech-0.7.0-models', 77 | silenceThreshold: 200, 78 | vadMode: 'VERY_AGGRESSIVE', 79 | debug: true 80 | }, function (err, deepspeech) { 81 | console.log('deepspeech service ready'); 82 | 83 | deepspeech.on('recognize', function (text, stats) { 84 | console.log('recognize', text, stats); 85 | 86 | // encode deepspeech results as JSON to be sent to the mainWindow 87 | let code = 'deepspeechResults(' + JSON.stringify(text) + ',' + JSON.stringify(stats) + ')'; 88 | 89 | executeJavaScript(mainWindow, code, function () { 90 | console.log('exec code complete'); 91 | }); 92 | }); 93 | 94 | // receive microphone audio stream from browser window 95 | ipcMain.on('stream-data', (event, data) => { 96 | console.log('data', data.buffer.readInt16LE); 97 | // debugger; 98 | // stream to the data to the DeepSpeech forked process 99 | deepspeech.streamData(data); 100 | }); 101 | 102 | }); 103 | 104 | } 105 | 106 | app.on('ready', function () { 107 | createWindow(); 108 | }); 109 | 110 | app.on('window-all-closed', () => { 111 | if (process.platform !== 'darwin') { 112 | app.quit(); 113 | } 114 | }); 115 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/favicon.ico -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 28 | Jaxcore DeepSpeech Example 29 | 30 | 31 | 32 |
33 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/logo192.png -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/electron-example/public/logo512.png -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/public/preload.js: -------------------------------------------------------------------------------- 1 | window.ipcRenderer = require('electron').ipcRenderer; 2 | console.log('ipcRenderer', window.ipcRenderer); -------------------------------------------------------------------------------- /examples/not_working/electron-example/src/JaxcoreElectronApp.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import BumbleBee, {SpectrumAnalyser} from 'bumblebee-hotword'; 3 | 4 | const ipcRenderer = window.ipcRenderer; 5 | 6 | let bumblebee = new BumbleBee(); 7 | bumblebee.setWorkersPath('./bumblebee-workers'); 8 | bumblebee.addHotword('bumblebee'); 9 | bumblebee.addHotword('grasshopper'); 10 | bumblebee.addHotword('hey_edison'); 11 | bumblebee.addHotword('porcupine'); 12 | bumblebee.addHotword('terminator'); 13 | bumblebee.setHotword('bumblebee'); 14 | 15 | window.deepspeechResults = function () {}; 16 | 17 | class JaxcoreDeepSpeechElectronApp extends Component { 18 | constructor() { 19 | super(); 20 | this.state = { 21 | started: false, 22 | output: [] 23 | }; 24 | } 25 | 26 | componentDidMount() { 27 | // ensure electron IPC is working: 28 | setTimeout(() => { 29 | console.log('send client-ready'); 30 | window.ipcRenderer.send('client-ready'); 31 | }, 1); 32 | ipcRenderer.on('electron-ready', () => { 33 | console.log('electron ready'); 34 | this.start(); 35 | }); 36 | 37 | // receive speech recognition result by a synchronous message from public/electron.js 38 | window.deepspeechResults = (text, stats) => { 39 | console.log('deepspeech results', text, stats); 40 | // debugger; 41 | const {output} = this.state; 42 | output.unshift({ 43 | text 44 | }); 45 | this.setState({output}); 46 | }; 47 | } 48 | 49 | start() { 50 | bumblebee.on('hotword', (hotword) => { 51 | console.log('hotword', hotword); 52 | const {output} = this.state; 53 | output.unshift({ 54 | hotword 55 | }); 56 | this.setState({output}); 57 | }); 58 | 59 | bumblebee.on('data', (data) => { 60 | // stream microphone audio to electron, which streams it to jaxcore-deepspeech-plugin, see public/electron.js 61 | ipcRenderer.send('stream-data', data); 62 | }); 63 | 64 | bumblebee.on('analyser', (analyser) => { 65 | console.log('analyser', analyser); 66 | var canvas = document.getElementById('oscilloscope'); 67 | this.analyser = new SpectrumAnalyser(analyser, canvas); 68 | this.analyser.setLineColor('#fff'); 69 | this.analyser.setBackgroundColor('#222'); 70 | this.analyser.start(); 71 | }); 72 | 73 | bumblebee.start(); 74 | 75 | this.setState({started: true}); 76 | } 77 | 78 | render() { 79 | if (!this.state.started) { 80 | return 'loading...'; 81 | } 82 | return (
83 |

DeepSpeech Electron Example

84 | 85 |
86 | Active Hotwords: "bumblebee", "grasshopper", "hey edison", "porcupine", "terminator" 87 |
88 | 89 |
90 | 91 |
92 | 93 | 100 |
); 101 | } 102 | 103 | renderOutputLine(line, id) { 104 | if (line.hotword) { 105 | return (
  • HOTWORD: {line.hotword}
  • ); 106 | } 107 | else { 108 | return (
  • SPEECH: {line.text}
  • ); 109 | } 110 | } 111 | } 112 | 113 | export default JaxcoreDeepSpeechElectronApp; -------------------------------------------------------------------------------- /examples/not_working/electron-example/src/JaxcoreElectronApp.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import JaxcoreElectronApp from './JaxcoreElectronApp'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/src/index.css: -------------------------------------------------------------------------------- 1 | html { 2 | background-color: #fff; 3 | } 4 | body { 5 | margin: 0; 6 | font-family: "Roboto", sans-serif; 7 | font-weight: normal; 8 | -webkit-font-smoothing: antialiased; 9 | -moz-osx-font-smoothing: grayscale; 10 | } 11 | 12 | code { 13 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 14 | monospace; 15 | } 16 | -------------------------------------------------------------------------------- /examples/not_working/electron-example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import JaxcoreElectronApp from './JaxcoreElectronApp'; 5 | 6 | ReactDOM.render(, document.getElementById('root')); 7 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extension-basic-example", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "react": "^16.12.0", 10 | "react-dom": "^16.12.0", 11 | "react-scripts": "3.3.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-basic/public/favicon.ico -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
    32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-basic/public/logo192.png -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-basic/public/logo512.png -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/src/App.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const Jaxcore = require('jaxcore'); 4 | const jaxcore = new Jaxcore(); 5 | jaxcore.addPlugin(require('jaxcore-websocket-plugin/websocket-client')); 6 | jaxcore.addPlugin(require('jaxcore-websocket-plugin/browser-service')); 7 | 8 | class App extends Component { 9 | constructor(props) { 10 | super(props); 11 | this.state = { 12 | loading: true, 13 | extensionReady: false, 14 | extensionConnected: false, 15 | websocketConnected: false, 16 | browserServiceId: null, 17 | portConnected: false, 18 | tabActive: false, 19 | spins: [], 20 | updates: [], 21 | spokenList: [] 22 | } 23 | } 24 | 25 | componentDidMount() { 26 | jaxcore.on('service-connected', (type, device) => { 27 | if (type === 'browserService') { 28 | this.extensionConnected(device); 29 | } 30 | }); 31 | 32 | jaxcore.on('device-connected', (type, device) => { 33 | if (type === 'speech') { 34 | 35 | // receive the speech device 36 | 37 | const speech = device; 38 | 39 | speech.on('recognize', (text) => { 40 | 41 | // listen for the "recognize" event 42 | 43 | const spokenList = this.state.spokenList; 44 | spokenList.unshift(text); 45 | this.setState({spokenList}); 46 | }); 47 | } 48 | 49 | }); 50 | 51 | jaxcore.connectBrowser(); 52 | } 53 | 54 | extensionConnected(browserService) { 55 | browserService.on('extension-disconnected', () => { 56 | debugger; 57 | this.setState({ 58 | extensionReady: false, 59 | extensionConnected: false, 60 | browserServiceId: null 61 | }); 62 | }); 63 | 64 | browserService.on('extension-connected', (msg) => { 65 | this.setState({ 66 | extensionConnected: msg.extensionConnected, 67 | tabActive: msg.tabActive, 68 | grantedPrivileges: msg.grantedPrivileges, 69 | websocketConnected: msg.websocketConnected 70 | }); 71 | }); 72 | 73 | browserService.on('websocket-connected', (websocketConnected) => { 74 | this.setState({ 75 | websocketConnected 76 | }); 77 | }); 78 | 79 | 80 | browserService.on('port-active', (portActive) => { 81 | this.setState({ 82 | tabActive: portActive 83 | }); 84 | }); 85 | 86 | this.setState({ 87 | extensionReady: true, 88 | extensionConnected: false, 89 | tabActive: false, 90 | browserServiceId: browserService.id 91 | }); 92 | } 93 | 94 | render() { 95 | return ( 96 |
    97 |

    Browser Extension:

    98 |
    99 |
    Extension: {this.state.extensionConnected ? this.state.browserServiceId + ' Connected' : 'Disconnected'}
    100 |
    WebSocket: {this.state.websocketConnected ? 'Connected' : 'Disconnected'}
    101 |
    Tab: {this.state.tabActive ? 'Active' : 'Inactive'}
    102 |
    103 | 104 |

    Speech Recognition Results:

    105 |
      106 | {this.state.spokenList.map((text, index) => { 107 | return (
    • {text}
    • ); 108 | })} 109 |
    110 | 111 |
    112 | ); 113 | } 114 | } 115 | 116 | export default App; 117 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /examples/not_working/extension-basic/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extension-basic-example", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "react": "^16.12.0", 10 | "react-dom": "^16.12.0", 11 | "react-scripts": "3.3.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-voice-keyboard/public/favicon.ico -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
    32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-voice-keyboard/public/logo192.png -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/extension-voice-keyboard/public/logo512.png -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | /*margin: 0;*/ 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | h1 { 11 | /*width: 1010px;*/ 12 | width: 100%; 13 | text-align: center; 14 | margin: auto; 15 | /*margin-bottom: -50px;*/ 16 | } 17 | 18 | #keyboard-hover { 19 | position: absolute; 20 | min-width: 100px; 21 | background: #eee; 22 | visibility: hidden; 23 | text-align: center; 24 | padding: 10px; 25 | } 26 | #keyboard { 27 | width: 1010px; 28 | margin: auto; 29 | } 30 | #keyboard div.row { 31 | white-space: nowrap; 32 | } 33 | #keyboard a.key { 34 | display: inline-block; 35 | width:50px; 36 | height:50px; 37 | border: 1px solid black; 38 | border-radius: 5px; 39 | margin: 2px; 40 | position: relative; 41 | color: black; 42 | } 43 | 44 | #keyboard a.key.highlighted { 45 | background: blue; 46 | color: white; 47 | } 48 | 49 | #keyboard a.key:hover { 50 | background: #eee; 51 | } 52 | 53 | #keyboard a.key.highlighted:hover { 54 | background: black; 55 | } 56 | 57 | #keyboard div.display { 58 | position: absolute; 59 | font-size: 13pt; 60 | text-align: center; 61 | width:inherit; 62 | top: 13px; 63 | } 64 | #keyboard div.displayWithShift { 65 | position: absolute; 66 | font-size: 13pt; 67 | top: 21px; 68 | text-align: center; 69 | width:inherit; 70 | } 71 | #keyboard div.shiftDisplay { 72 | position: absolute; 73 | top: 1px; 74 | font-size: 11pt; 75 | text-align: center; 76 | width:inherit; 77 | } 78 | 79 | #keyboard div.key-empty { 80 | display: inline-block; 81 | width:52px; 82 | height:52px; 83 | margin: 2px; 84 | } 85 | 86 | #keyboard a.key.key-escape, 87 | #keyboard a.key.key-f1, 88 | #keyboard a.key.key-f2, 89 | #keyboard a.key.key-f3, 90 | #keyboard a.key.key-f4, 91 | #keyboard a.key.key-f5, 92 | #keyboard a.key.key-f6, 93 | #keyboard a.key.key-f7, 94 | #keyboard a.key.key-f8, 95 | #keyboard a.key.key-f9, 96 | #keyboard a.key.key-f10, 97 | #keyboard a.key.key-f11, 98 | #keyboard a.key.key-f12 { 99 | height: 25px; 100 | } 101 | #keyboard a.key.key-escape div.display, 102 | #keyboard a.key.key-f1 div.display, 103 | #keyboard a.key.key-f2 div.display, 104 | #keyboard a.key.key-f3 div.display, 105 | #keyboard a.key.key-f4 div.display, 106 | #keyboard a.key.key-f5 div.display, 107 | #keyboard a.key.key-f6 div.display, 108 | #keyboard a.key.key-f7 div.display, 109 | #keyboard a.key.key-f8 div.display, 110 | #keyboard a.key.key-f9 div.display, 111 | #keyboard a.key.key-f10 div.display, 112 | #keyboard a.key.key-f11 div.display, 113 | #keyboard a.key.key-f12 div.display { 114 | top: 1px; 115 | } 116 | 117 | #keyboard a.key.key-tab { 118 | width:75px; 119 | } 120 | #keyboard a.key.key-backslash { 121 | width:75px; 122 | } 123 | #keyboard a.key.key-backspace { 124 | width:100px; 125 | } 126 | 127 | #keyboard a.key.key-return { 128 | width:103px; 129 | } 130 | #keyboard a.key.key-capslock { 131 | width:103px; 132 | } 133 | 134 | #keyboard a.key.key-shift, 135 | #keyboard a.key.key-right-shift { 136 | width: 131px; 137 | } 138 | 139 | #keyboard a.key.key-command, 140 | #keyboard a.key.key-right-command { 141 | width: 70px; 142 | } 143 | 144 | #keyboard a.key.key-space { 145 | width: 452px; 146 | } 147 | 148 | #keyboard a.key.key-up, 149 | #keyboard a.key.key-insert, 150 | #keyboard a.key.key-delete, 151 | #keyboard a.key.key-left { 152 | margin-left: 10px; 153 | } 154 | -------------------------------------------------------------------------------- /examples/not_working/extension-voice-keyboard/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | ReactDOM.render(, document.getElementById('root')); 7 | 8 | -------------------------------------------------------------------------------- /examples/not_working/jaxcore-deepspeech-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/not_working/jaxcore-deepspeech-adapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jaxcore-deepspeech-adapter", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/not_working/jaxcore-deepspeech-adapter/start.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const jaxcore = new Jaxcore(); 3 | 4 | // PLUGINS 5 | 6 | jaxcore.addPlugin(require('bumblebee-hotword-node')); 7 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 8 | 9 | // SERVICES 10 | 11 | jaxcore.defineService('Bumblebee Node', 'bumblebeeNode', {}); 12 | 13 | jaxcore.defineService('Deepspeech English', 'deepspeech', { 14 | modelName: 'english', 15 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model 16 | silenceThreshold: 200, 17 | vadMode: 'VERY_AGGRESSIVE', 18 | debug: true 19 | }); 20 | 21 | // ADAPTER 22 | 23 | class BumblebeeDeepspeechAdapter extends Jaxcore.Adapter { 24 | constructor(store, config, theme, devices, services) { 25 | super(store, config, theme, devices, services); 26 | 27 | const {deepspeech, bumblebeeNode} = services; 28 | 29 | bumblebeeNode.setHotword('bumblebee'); 30 | 31 | this.addEvents(deepspeech, { 32 | recognize: function(text, stats) { 33 | console.log('Recognized:', text, stats); 34 | } 35 | }); 36 | 37 | this.addEvents(bumblebeeNode, { 38 | hotword: function(hotword) { 39 | console.log('\n[hotword detected:', hotword, ']'); 40 | }, 41 | data: function (data) { 42 | deepspeech.streamData(data); 43 | } 44 | }); 45 | 46 | bumblebeeNode.start(); 47 | 48 | // setTimeout(() => { 49 | // deepspeech.destroy(); 50 | // }, 10000); 51 | } 52 | } 53 | 54 | jaxcore.addAdapter('bumblebee-deepspeech-adapter', BumblebeeDeepspeechAdapter); 55 | 56 | // CONNECT THE "bumblebee-deepspeech-adapter" ADAPTER TO THE "Bumblebee Node" AND "Deepspeech English" SERVICES 57 | 58 | jaxcore.defineAdapter('BumbleBee Deepspeech', { 59 | adapterType: 'bumblebee-deepspeech-adapter', 60 | serviceProfiles: [ 61 | 'Bumblebee Node', 62 | 'Deepspeech English' 63 | ] 64 | }); 65 | 66 | jaxcore.connectAdapter(null, 'BumbleBee Deepspeech'); 67 | -------------------------------------------------------------------------------- /examples/not_working/kodi-control/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/not_working/kodi-control/README.md: -------------------------------------------------------------------------------- 1 | # Jaxcore Kodi Speech Example 2 | 3 | This is a NodeJS example that uses DeepSpeech to control [Kodi Media Center](https://kodi.tv/). 4 | 5 | The voice commands to control Kodi implemented (so far) are 6 | 7 | - up 8 | - down 9 | - left 10 | - right 11 | - select 12 | - back 13 | - pause 14 | - play 15 | - stop 16 | - page up 17 | - page down 18 | 19 | --- 20 | 21 | ### Installation 22 | 23 | ``` 24 | git clone https://github.com/jaxcore/deepspeech-plugin 25 | cd deepspeech-plugin 26 | npm install 27 | ``` 28 | 29 | #### Download DeepSpeech Pre-Trained english model: 30 | 31 | If the DeepSpeech models have not previously been downloaded, do so now (beware this is a large download >1.8GB): 32 | 33 | ``` 34 | wget https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz 35 | tar xfvz deepspeech-0.6.0-models.tar.gz 36 | rm deepspeech-0.6.0-models.tar.gz 37 | ``` 38 | 39 | Go do the example directory: 40 | 41 | ``` 42 | cd examples/jaxcore-kodi-speech-adapter 43 | ``` 44 | 45 | Install: 46 | 47 | ``` 48 | npm install 49 | ``` 50 | 51 | Start the server: 52 | 53 | ``` 54 | node start.js 55 | ``` 56 | 57 | By default it connects to Kodi running on `localhost` port 9090 (you must configure Kodi remote control settings to [allow access](https://yatse.tv/img/wiki/kodi-configuration/04.jpg)). 58 | 59 | To connect to Kodi running on other computers on your home network use the `KODI_HOST` environment variable to set the hostname or IP Address of the computer running Kodi: 60 | 61 | ``` 62 | KODI_HOST=192.168.1.100 node start 63 | ``` 64 | 65 | #### Alternative deepspeech model directory 66 | 67 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 68 | 69 | ``` 70 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 71 | ``` 72 | 73 | It is possible to use both `DEEPSPEECH_MODEL` and `KODI_HOST` variables if necessary: 74 | 75 | ``` 76 | DEEPSPEECH_MODEL=/path/to/deepspeech/models KODI_HOST=192.168.1.100 node start.js 77 | ``` 78 | 79 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/not_working/kodi-control/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kodi-control-example", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "jaxcore-kodi-plugin": "git+https://github.com/jaxcore/kodi-plugin.git" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/not_working/kodi-control/start.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const jaxcore = new Jaxcore(); 3 | 4 | // PLUGINS 5 | 6 | jaxcore.addPlugin(require('jaxcore-kodi-plugin')); 7 | jaxcore.addPlugin(require('bumblebee-hotword-node')); 8 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 9 | 10 | // SERVICES 11 | 12 | jaxcore.defineService('Kodi', 'kodi', { 13 | host: process.env.KODI_HOST || 'localhost', 14 | port: 9090 15 | }); 16 | jaxcore.defineService('Bumblebee Node', 'bumblebeeNode', {}); 17 | jaxcore.defineService('Deepspeech English', 'deepspeech', { 18 | modelName: 'english', 19 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model 20 | silenceThreshold: 200, 21 | vadMode: 'VERY_AGGRESSIVE', 22 | debug: true 23 | }); 24 | 25 | // ADAPTER 26 | 27 | class KodiSpeechAdapter extends Jaxcore.Adapter { 28 | constructor(store, config, theme, devices, services) { 29 | super(store, config, theme, devices, services); 30 | const {kodi, deepspeech, bumblebeeNode} = services; 31 | 32 | this.addEvents(deepspeech, { 33 | recognize: function (text, stats) { 34 | this.log('speech recognize', text); 35 | 36 | if (text === 'page up') { 37 | console.log('page up'); 38 | kodi.pageUp(); 39 | } 40 | if (text === 'page down') { 41 | console.log('page down'); 42 | kodi.pageDown(); 43 | } 44 | if (text === 'up') { 45 | console.log('arrow up'); 46 | kodi.up(-1); 47 | } 48 | if (text === 'down') { 49 | console.log('arrow down'); 50 | kodi.down(1); 51 | } 52 | if (text === 'left') { 53 | console.log('arrow left'); 54 | kodi.left(-1); 55 | } 56 | if (text === 'right') { 57 | console.log('arrow right'); 58 | kodi.right(1); 59 | } 60 | if (text === 'select') { 61 | console.log('select'); 62 | kodi.select(); 63 | } 64 | if (text === 'pause') { 65 | console.log('pause'); 66 | kodi.playPause(); 67 | } 68 | if (text === 'play') { 69 | console.log('play'); 70 | kodi.playPause(); 71 | } 72 | if (text === 'back') { 73 | console.log('back'); 74 | kodi.back(); 75 | } 76 | if (text === 'stop') { 77 | console.log('stop'); 78 | kodi.stop(); 79 | } 80 | } 81 | }); 82 | 83 | this.addEvents(bumblebeeNode, { 84 | hotword: function(hotword) { 85 | console.log('\n[hotword detected:', hotword, ']'); 86 | }, 87 | data: function (data) { 88 | deepspeech.streamData(data); 89 | } 90 | }); 91 | 92 | bumblebeeNode.start(); 93 | } 94 | } 95 | 96 | jaxcore.addAdapter('kodi-speech', KodiSpeechAdapter); 97 | 98 | // CONNECT THE "kodi-speech" ADAPTER TO THE SERVICES 99 | 100 | jaxcore.defineAdapter('Kodi Speech', { 101 | adapterType: 'kodi-speech', 102 | serviceProfiles: [ 103 | 'Bumblebee Node', 104 | 'Deepspeech English', 105 | 'Kodi' 106 | ] 107 | }); 108 | 109 | jaxcore.connectAdapter(null, 'Kodi Speech'); 110 | -------------------------------------------------------------------------------- /examples/not_working/mouse-control/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/not_working/mouse-control/README.md: -------------------------------------------------------------------------------- 1 | # Jaxcore Voice Mouse Example 2 | 3 | This is a NodeJS example that connects DeepSpeech to the [Jaxcore](https://github.com/jaxcore/jaxcore) Mouse Service. It uses voice commands to control the computer mouse. 4 | 5 | The voice commands are: 6 | 7 | - mouse left `N` // moves mouse `N` pixels to the left 8 | - mouse right `N` // moves mouse `N` pixels to the right 9 | - mouse up `N` // moves mouse `N` pixels to the right 10 | - mouse down `N` // moves mouse `N` pixels to the right 11 | - scroll left 12 | - scroll right 13 | - scroll up 14 | - scroll down 15 | - page up 16 | - page down 17 | - left click 18 | - right click 19 | - middle click 20 | 21 | 22 | --- 23 | 24 | ### Installation 25 | 26 | ``` 27 | npm install 28 | ``` 29 | 30 | Start the server: 31 | 32 | ``` 33 | node start.js 34 | ``` 35 | 36 | #### Alternative deepspeech model directory 37 | 38 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 39 | 40 | ``` 41 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 42 | ``` 43 | 44 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/not_working/mouse-control/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mouse-control-example", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "numerizer": "git+https://github.com/dsteinman/numerizerJS.git" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/not_working/number-typer/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/not_working/number-typer/README.md: -------------------------------------------------------------------------------- 1 | # Number Typer 2 | 3 | This is a NodeJS example that connects [DeepSpeech](https://github.com/mozilla/DeepSpeech) to the [Jaxcore](https://github.com/jaxcore/jaxcore) Keyboard Service. It uses speech recognition to type numbers keys (and more) on the computer. This works system-wide - use it for a Calculator or Spreadsheet application, terminal commands, or anything else. You'll never have to type another number with your hands again. 4 | 5 | For more information about the Jaxcore DeepSpeech plugin see [here](https://github.com/jaxcore/deepspeech-plugin). 6 | 7 | ## Voice Commands 8 | 9 | Supported words / commands. Saying these words presses the corresponding key(s) on the keyboard: 10 | 11 | - all numbers: 12 | - "one" `1` 13 | - "fifty" `50` 14 | - "negative one fifty" `-150` 15 | - "five hundred" `500` 16 | - "five thousand and five" `5005` 17 | - "twenty four million and five" `24000005` 18 | - floating point numbers: 19 | - "one point five" `1.5` 20 | - "sixteen decminal zero one" `16.01` 21 | - all math-related symbols: 22 | - "plus" `+` 23 | - "minus" `-` 24 | - "times" `*` 25 | - "equals" `=` 26 | - "diviced by" `/` 27 | - specific keys: 28 | - "space" 29 | - "tab" 30 | - "enter" 31 | - "escape" 32 | - "home" 33 | - "end" 34 | - "delete" 35 | - "backspace" 36 | - "comma" `,` 37 | - "colon" `:` 38 | - "semi colon" `;` 39 | - "left brace" `[` or "right brace" `]` 40 | - "left curly backet" `{`or "left curly backet" `]` 41 | - "left bracket `(` or "right bracket" `)` 42 | - arrow keys: 43 | - "up" 44 | - "down" 45 | - "left" 46 | - "right" 47 | - modifier + direction: 48 | - "shift left" 49 | - "option left" OR "alt left" 50 | - "control left" 51 | - "command left" 52 | - "option shift left" 53 | - "hold shift" and "release shift" 54 | - "select all" - presses `Command-A` 55 | - "copy" - presses `Control-C` (win/linux) and `Command-C` (mac) 56 | - "paste" - presses `Control-V` (win/linux) or `Command-V` (mac) 57 | 58 | 59 | ## Installation 60 | 61 | ``` 62 | npm install 63 | ``` 64 | 65 | Mac OSX users will have to install an alternative speaker backend: 66 | 67 | ``` 68 | npm install speaker --mpg123-backend=openal --no-save 69 | ``` 70 | 71 | Start the server: 72 | 73 | ``` 74 | node start.js 75 | ``` 76 | 77 | #### Alternative deepspeech model directory 78 | 79 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 80 | 81 | ``` 82 | DEEPSPEECH_MODEL=/path/to/deepspeech/models node start.js 83 | ``` 84 | 85 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/not_working/number-typer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "number-typer", 3 | "version": "0.0.0", 4 | "description": "uses deepspeech to type numbers on the keyboard", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "jaxcore-say-node": "0.0.6", 16 | "numerizer": "git+https://github.com/dsteinman/numerizerJS.git", 17 | "wav": "^1.0.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/not_working/number-typer/test/parser.test.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai'); 2 | const expect = chai.expect; 3 | const NumbersDatesNLP = require('../lib/numbers-nlp'); 4 | 5 | let numberParser = new NumbersDatesNLP({ 6 | numbers: true 7 | }); 8 | 9 | // let dateParser = new NumbersDatesNLP({ 10 | // dates: true 11 | // }); 12 | // 13 | // let numbersAndDatesParser = new NumbersDatesNLP({ 14 | // numbers: true, 15 | // dates: true 16 | // }); 17 | 18 | describe('Color class constructor', function() { 19 | it('accepts strings', function(done) { 20 | expect(numberParser.parse("one")).to.be.equal('1'); 21 | done(); 22 | }); 23 | }); 24 | 25 | // let keys = parseKeys('one space to select all delete five option right nine greater than semi colon'); 26 | // let keys = parseKeys('one space to back space five dot dash nine greater than semi colon select all copy right enter paste shift option left shift option left shift option left'); 27 | // let keys = parseKeys('one to three for shift option left shift option left shift option left'); 28 | // let keys = parseKeys('one option shift right two option shift right three option shift right'); 29 | // let keys = parseKeys('one to three for shift left shift left shift left copy left paste left left enter option shift right copy'); 30 | // let keys = parseKeys('one to three shift left shift left shift left one shift left copy semi colon twelve'); 31 | // let keys = parseKeys('for i\'ve'); 32 | // let keys = parseKeys('there'); 33 | // console.log(keys); 34 | // process.exit(); 35 | 36 | 37 | // setTimeout(function() { 38 | // // keyboard.keyPress('4'); 39 | // // keyboard.keyPress('*'); 40 | // // keyboard.keyPress('4'); 41 | // // keyboard.keyPress('='); 42 | // // keyboard.keyPress('+'); 43 | // // keyboard.keyPress('2'); 44 | // // keyboard.keyPress('='); 45 | // 46 | // // process.exit(); 47 | // }, 2000); 48 | 49 | // console.log('\nnumbers:', wordsToNumbers("twenty four million", { impliedHundreds: true })); 50 | // console.log('\nnumbers:', parseKeys("negative one fifty", { impliedHundreds: true })); 51 | // process.exit(); 52 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/README.md: -------------------------------------------------------------------------------- 1 | # Web Basic Example 2 | 3 | This is an example of a ReactJS web application streaming microphone audio from the browser 4 | to a NodeJS server and transmitting the DeepSpeech results back to the browser. 5 | 6 | #### Install 7 | 8 | ``` 9 | yarn install 10 | ``` 11 | 12 | #### Run ReactJS Client 13 | 14 | ``` 15 | yarn start 16 | ``` 17 | 18 | #### Run NodeJS Server (in a separate terminal window) 19 | 20 | ``` 21 | node server.js 22 | ``` 23 | 24 | #### Alternative deepspeech model directory 25 | 26 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 27 | 28 | ``` 29 | DEEPSPEECH_MODEL=/path/to/deepspeech-models node server.js 30 | ``` 31 | 32 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-basic-example", 3 | "version": "0.0.2", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "bumblebee-hotword": "^0.0.6", 10 | "chai": "^4.2.0", 11 | "chai-http": "^4.3.0", 12 | "defaults": "^1.0.3", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "mocha": "^6.1.4", 16 | "node-vad": "^1.1.4", 17 | "react": "^16.12.0", 18 | "react-dom": "^16.12.0", 19 | "react-scripts": "3.3.0", 20 | "should": "^13.2.3", 21 | "should-http": "^0.1.1", 22 | "socket.io": "^2.3.0", 23 | "socket.io-client": "^2.3.0" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test:client": "react-scripts test --env=jsdom --watchAll=false --coverage", 29 | "test:server": "NODE_ENV=dev mocha --recursive ./test/config.js ./test --exit", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": "react-app" 34 | }, 35 | "browserslist": { 36 | "production": [ 37 | ">0.2%", 38 | "not dead", 39 | "not op_mini all" 40 | ], 41 | "development": [ 42 | "last 1 chrome version", 43 | "last 1 firefox version", 44 | "last 1 safari version" 45 | ] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/bumblebee-workers/downsampling_worker.js: -------------------------------------------------------------------------------- 1 | // https://github.com/Picovoice/web-voice-processor/blob/master/src/downsampling_worker.js 2 | 3 | onmessage = function (e) { 4 | switch (e.data.command) { 5 | case "init": 6 | init(e.data.inputSampleRate); 7 | break; 8 | case "process": 9 | process(e.data.inputFrame); 10 | break; 11 | case "reset": 12 | reset(); 13 | break; 14 | } 15 | }; 16 | 17 | let inputSampleRate; 18 | let inputBuffer = []; 19 | 20 | function init(x) { 21 | inputSampleRate = x; 22 | } 23 | 24 | function process(inputFrame) { 25 | for (let i = 0; i < inputFrame.length; i++) { 26 | inputBuffer.push((inputFrame[i]) * 32767); 27 | } 28 | 29 | const PV_SAMPLE_RATE = 16000; 30 | const PV_FRAME_LENGTH = 512; 31 | 32 | while ((inputBuffer.length * PV_SAMPLE_RATE / inputSampleRate) > PV_FRAME_LENGTH) { 33 | let outputFrame = new Int16Array(PV_FRAME_LENGTH); 34 | let sum = 0; 35 | let num = 0; 36 | let outputIndex = 0; 37 | let inputIndex = 0; 38 | 39 | while (outputIndex < PV_FRAME_LENGTH) { 40 | sum = 0; 41 | num = 0; 42 | while (inputIndex < Math.min(inputBuffer.length, (outputIndex + 1) * inputSampleRate / PV_SAMPLE_RATE)) { 43 | sum += inputBuffer[inputIndex]; 44 | num++; 45 | inputIndex++; 46 | } 47 | outputFrame[outputIndex] = sum / num; 48 | outputIndex++; 49 | } 50 | 51 | postMessage(outputFrame); 52 | 53 | inputBuffer = inputBuffer.slice(inputIndex); 54 | } 55 | } 56 | 57 | function reset() { 58 | inputBuffer = []; 59 | } -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/bumblebee-workers/porcupine.js: -------------------------------------------------------------------------------- 1 | let Porcupine = (function () { 2 | /** 3 | * Binding for wake word detection object. It initializes the JS binding for WebAssembly module and exposes 4 | * a factory method for creating new instances of wake word engine. 5 | */ 6 | 7 | let initWasm = null; 8 | let releaseWasm = null; 9 | let processWasm = null; 10 | let sampleRate = null; 11 | let frameLength = null; 12 | let version = null; 13 | 14 | let porcupineModule = PorcupineModule(); 15 | porcupineModule.then(function(Module) { 16 | initWasm = Module.cwrap('pv_porcupine_wasm_init', 'number', ['number', 'number', 'number', 'number']); 17 | releaseWasm = Module.cwrap('pv_porcupine_wasm_delete', ['number']); 18 | processWasm = Module.cwrap('pv_porcupine_wasm_process', 'number', ['number', 'number']); 19 | sampleRate = Module.cwrap('pv_wasm_sample_rate', 'number', [])(); 20 | frameLength = Module.cwrap('pv_porcupine_wasm_frame_length', 'number', [])(); 21 | version = Module.cwrap('pv_porcupine_wasm_version', 'string', [])(); 22 | }); 23 | 24 | let isLoaded = function() { 25 | /** 26 | * Flag indicating if 'PorcupineModule' is loaded. .create() can only be called after loading is finished. 27 | */ 28 | return initWasm != null; 29 | }; 30 | 31 | let create = function (keywordIDs, sensitivities) { 32 | /** 33 | * Creates an instance of wake word detection engine (aka porcupine). Can be called only after .isLoaded() 34 | * returns true. 35 | * @param {Array} Array of keyword IDs. A keyword ID is the signature for a given phrase to be detected. Each 36 | * keyword ID should be stored as UInt8Array. 37 | * @param {Float32Array} Detection sensitivity. A higher sensitivity reduces miss rate at the cost of higher 38 | * false alarm rate. Sensitivity is a number within [0, 1]. 39 | * @returns An instance of wake word detection engine. 40 | */ 41 | let keywordIDSizes = Int32Array.from(keywordIDs.map(keywordID => keywordID.byteLength)); 42 | let keywordIDSizesPointer = porcupineModule._malloc(keywordIDSizes.byteLength); 43 | let keywordIDSizesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, keywordIDSizesPointer, keywordIDSizes.byteLength); 44 | keywordIDSizesBuffer.set(new Uint8Array(keywordIDSizes.buffer)); 45 | 46 | let keywordIDPointers = Uint32Array.from(keywordIDs.map(keywordID => { 47 | let heapPointer = porcupineModule._malloc(keywordID.byteLength); 48 | let heapBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, heapPointer, keywordID.byteLength); 49 | heapBuffer.set(keywordID); 50 | return heapPointer; 51 | })); 52 | 53 | let keywordIDPointersPointer = porcupineModule._malloc(keywordIDPointers.byteLength); 54 | let keywordIDPointersBuffer = new Uint8Array( 55 | porcupineModule.HEAPU8.buffer, 56 | keywordIDPointersPointer, 57 | keywordIDPointers.byteLength); 58 | keywordIDPointersBuffer.set(new Uint8Array(keywordIDPointers.buffer)); 59 | 60 | let sensitivitiesPointer = porcupineModule._malloc(sensitivities.byteLength); 61 | let sensitivitiesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, sensitivitiesPointer, sensitivities.byteLength); 62 | sensitivitiesBuffer.set(new Uint8Array(sensitivities.buffer)); 63 | 64 | let handleWasm = initWasm( 65 | keywordIDs.length, 66 | keywordIDSizesPointer, 67 | keywordIDPointersPointer, 68 | sensitivitiesPointer); 69 | if (handleWasm === 0) { 70 | throw new Error("failed to initialize porcupine."); 71 | } 72 | 73 | let pcmWasmPointer = porcupineModule._malloc(frameLength * 2); 74 | 75 | let release = function () { 76 | /** 77 | * Releases resources acquired by WebAssembly module. 78 | */ 79 | 80 | releaseWasm(handleWasm); 81 | porcupineModule._free(pcmWasmPointer); 82 | }; 83 | 84 | let process = function (pcmInt16Array) { 85 | /** 86 | * Processes a frame of audio. The required sample rate can be retrieved from .sampleRate and the length of 87 | * frame (number of samples within frame) can be retrieved from .frameLength. 88 | * @param {Int16Array} A frame of audio with properties described above. 89 | * @returns {Number} Index of detected keyword (phrase). When no keyword is detected it returns -1. 90 | */ 91 | 92 | let pcmWasmBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, pcmWasmPointer, pcmInt16Array.byteLength); 93 | pcmWasmBuffer.set(new Uint8Array(pcmInt16Array.buffer)); 94 | 95 | let keyword_index = processWasm(handleWasm, pcmWasmPointer); 96 | if (keyword_index === -2) { 97 | throw new Error("porcupine failed to process audio"); 98 | } 99 | 100 | return keyword_index; 101 | }; 102 | 103 | return { 104 | release: release, 105 | process: process, 106 | sampleRate: sampleRate, 107 | frameLength: frameLength, 108 | version: version 109 | } 110 | }; 111 | 112 | return {isLoaded: isLoaded, create: create} 113 | })(); 114 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/bumblebee-workers/porcupine_worker.js: -------------------------------------------------------------------------------- 1 | importScripts("pv_porcupine.js"); 2 | importScripts("porcupine.js"); 3 | 4 | onmessage = function (e) { 5 | switch (e.data.command) { 6 | case "init": 7 | init(e.data.keywordIDs, e.data.sensitivities); 8 | break; 9 | case "process": 10 | process(e.data.inputFrame); 11 | break; 12 | case "release": 13 | release(); 14 | break; 15 | } 16 | }; 17 | 18 | let keywordIDArray; 19 | let keywords; 20 | let sensitivities; 21 | 22 | let porcupine = null; 23 | 24 | function init(keywordIDs, _sensitivities_) { 25 | keywordIDArray = Object.values(keywordIDs); 26 | keywords = Object.keys(keywordIDs); 27 | sensitivities = _sensitivities_; 28 | 29 | if (Porcupine.isLoaded()) { 30 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 31 | } 32 | } 33 | 34 | function process(inputFrame) { 35 | if (porcupine == null && Porcupine.isLoaded()) { 36 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 37 | } else if (porcupine != null) { 38 | let keywordIndex = porcupine.process(inputFrame); 39 | postMessage({keyword: keywordIndex === -1 ? null : keywords[keywordIndex]}); 40 | } 41 | } 42 | 43 | function release() { 44 | if (porcupine !== null) { 45 | porcupine.release(); 46 | } 47 | 48 | porcupine = null; 49 | } 50 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/bumblebee-workers/pv_porcupine.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-basic-example/public/bumblebee-workers/pv_porcupine.wasm -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-basic-example/public/favicon.ico -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | DeepSpeech - Web Microphone Websocket Example 28 | 29 | 30 | 31 |
    32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-basic-example/public/logo192.png -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-basic-example/public/logo512.png -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const socketIO = require('socket.io'); 3 | 4 | const Jaxcore = require('jaxcore'); 5 | const jaxcore = new Jaxcore(); 6 | 7 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 8 | 9 | const WEBSOCKET_SERVER_PORT = 4000; 10 | 11 | function startSocketServer(deepspeech) { 12 | const app = http.createServer(function (req, res) { 13 | res.writeHead(200); 14 | res.write('web-basic-example'); 15 | res.end(); 16 | }); 17 | 18 | const io = socketIO(app, {}); 19 | io.set('origins', '*:*'); 20 | 21 | io.on('connection', function (socket) { 22 | console.log('client connected'); 23 | 24 | socket.once('disconnect', () => { 25 | console.log('client disconnected'); 26 | }); 27 | 28 | deepspeech.on('recognize', (text, stats) => { 29 | socket.emit('recognize', text, stats); 30 | }); 31 | 32 | socket.on('stream-data', function (data) { 33 | deepspeech.streamData(data); 34 | }); 35 | socket.on('stream-end', function () { 36 | deepspeech.streamEnd(); 37 | }); 38 | socket.on('stream-reset', function () { 39 | deepspeech.streamReset(); 40 | }); 41 | }); 42 | 43 | app.listen(WEBSOCKET_SERVER_PORT, 'localhost', () => { 44 | console.log('Socket server listening on:', WEBSOCKET_SERVER_PORT); 45 | }); 46 | } 47 | 48 | // start the speech adapter (pay attention to the deepspeech modelPath location) 49 | jaxcore.startService('deepspeech', { 50 | modelName: 'english', 51 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model 52 | silenceThreshold: 200, 53 | vadMode: 'VERY_AGGRESSIVE', 54 | debug: true 55 | }, function(err, deepspeech) { 56 | console.log('deepspeech service ready', typeof deepspeech); 57 | startSocketServer(deepspeech); 58 | }); 59 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/src/App.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import io from 'socket.io-client'; 3 | 4 | import BumbleBee from 'bumblebee-hotword'; 5 | 6 | const bumblebee = new BumbleBee(); 7 | 8 | bumblebee.setSensitivity(0.5); 9 | bumblebee.setWorkersPath('./bumblebee-workers'); 10 | bumblebee.addHotword('bumblebee'); 11 | bumblebee.setHotword('bumblebee'); 12 | 13 | class App extends Component { 14 | constructor(props) { 15 | super(props); 16 | this.state = { 17 | connected: false, 18 | recording: false, 19 | recordingStart: 0, 20 | recordingTime: 0, 21 | recognitionOutput: [] 22 | }; 23 | } 24 | 25 | componentDidMount() { 26 | let recognitionCount = 0; 27 | 28 | this.socket = io.connect('http://localhost:4000', {}); 29 | 30 | this.socket.on('connect', () => { 31 | console.log('socket connected'); 32 | this.setState({connected: true}); 33 | }); 34 | 35 | this.socket.on('disconnect', () => { 36 | console.log('socket disconnected'); 37 | this.setState({connected: false}); 38 | this.stopRecording(); 39 | }); 40 | 41 | this.socket.on('recognize', (text, stats) => { 42 | console.log('recognized:', text, stats); 43 | const {recognitionOutput} = this.state; 44 | recognitionCount++; 45 | recognitionOutput.unshift({ 46 | id: recognitionCount, 47 | text, 48 | stats 49 | }); 50 | this.setState({recognitionOutput}); 51 | }); 52 | 53 | bumblebee.on('data', (data) => { 54 | if (this.state.connected) { 55 | this.socket.emit('stream-data', data.buffer); 56 | } 57 | }); 58 | } 59 | 60 | render() { 61 | return (
    62 |
    63 | 66 | 67 | 70 | 71 | {this.renderTime()} 72 |
    73 | {this.renderRecognitionOutput()} 74 |
    ); 75 | } 76 | 77 | renderTime() { 78 | return ( 79 | {(Math.round(this.state.recordingTime / 100) / 10).toFixed(1)}s 80 | ); 81 | } 82 | 83 | renderRecognitionOutput() { 84 | return (
      85 | {this.state.recognitionOutput.map((r) => { 86 | return (
    • {r.text}
    • ); 87 | })} 88 |
    ) 89 | } 90 | startRecording = e => { 91 | if (!this.state.recording) { 92 | this.recordingInterval = setInterval(() => { 93 | let recordingTime = new Date().getTime() - this.state.recordingStart; 94 | this.setState({recordingTime}); 95 | }, 100); 96 | 97 | this.setState({ 98 | recording: true, 99 | recordingStart: new Date().getTime(), 100 | recordingTime: 0 101 | }, () => { 102 | bumblebee.start(); 103 | }); 104 | } 105 | }; 106 | 107 | stopRecording = e => { 108 | if (this.state.recording) { 109 | if (this.socket.connected) { 110 | this.socket.emit('stream-end'); 111 | } 112 | clearInterval(this.recordingInterval); 113 | this.setState({ 114 | recording: false 115 | }, () => { 116 | bumblebee.stop(); 117 | }); 118 | } 119 | }; 120 | 121 | } 122 | 123 | export default App; 124 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /examples/not_working/web-basic-example/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/README.md: -------------------------------------------------------------------------------- 1 | # Bumblebee Hotword + DeepSpeech Example 2 | 3 | This is an example of using [Bumblebee-Hotword](https://github.com/jaxcore/bumblebee-hotword) in a web browser to activate/deactivate [DeepSpeech](https://github.com/mozilla/DeepSpeech) running in a NodeJS server. 4 | 5 | #### Install: 6 | 7 | ``` 8 | yarn install 9 | ``` 10 | 11 | #### Run ReactJS Client: 12 | 13 | ``` 14 | yarn start 15 | ``` 16 | 17 | #### Run NodeJS Server (in a separate terminal window): 18 | 19 | ``` 20 | node server.js 21 | ``` 22 | 23 | #### Alternative deepspeech model directory 24 | 25 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 26 | 27 | ``` 28 | DEEPSPEECH_MODEL=/path/to/deepspeech-models node server.js 29 | ``` 30 | 31 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-hotword-example", 3 | "version": "0.0.2", 4 | "dependencies": { 5 | "bumblebee-hotword": "0.0.6", 6 | "jaxcore": "0.0.2", 7 | "jaxcore-deepspeech-plugin": "0.0.6", 8 | "jaxcore-say": "0.0.5", 9 | "react": "^16.12.0", 10 | "react-dom": "^16.12.0", 11 | "react-scripts": "3.3.0", 12 | "socket.io": "^2.3.0", 13 | "socket.io-client": "^2.3.0", 14 | "numerizer": "git+https://github.com/dsteinman/numerizerJS.git" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": "react-app" 24 | }, 25 | "license": "MIT", 26 | "homepage": ".", 27 | "browserslist": [ 28 | ">0.2%", 29 | "not dead", 30 | "not ie <= 11", 31 | "not op_mini all" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/bumblebee-workers/downsampling_worker.js: -------------------------------------------------------------------------------- 1 | // https://github.com/Picovoice/web-voice-processor/blob/master/src/downsampling_worker.js 2 | 3 | onmessage = function (e) { 4 | switch (e.data.command) { 5 | case "init": 6 | init(e.data.inputSampleRate); 7 | break; 8 | case "process": 9 | process(e.data.inputFrame); 10 | break; 11 | case "reset": 12 | reset(); 13 | break; 14 | } 15 | }; 16 | 17 | let inputSampleRate; 18 | let inputBuffer = []; 19 | 20 | function init(x) { 21 | inputSampleRate = x; 22 | } 23 | 24 | function process(inputFrame) { 25 | for (let i = 0; i < inputFrame.length; i++) { 26 | inputBuffer.push((inputFrame[i]) * 32767); 27 | } 28 | 29 | const PV_SAMPLE_RATE = 16000; 30 | const PV_FRAME_LENGTH = 512; 31 | 32 | while ((inputBuffer.length * PV_SAMPLE_RATE / inputSampleRate) > PV_FRAME_LENGTH) { 33 | let outputFrame = new Int16Array(PV_FRAME_LENGTH); 34 | let sum = 0; 35 | let num = 0; 36 | let outputIndex = 0; 37 | let inputIndex = 0; 38 | 39 | while (outputIndex < PV_FRAME_LENGTH) { 40 | sum = 0; 41 | num = 0; 42 | while (inputIndex < Math.min(inputBuffer.length, (outputIndex + 1) * inputSampleRate / PV_SAMPLE_RATE)) { 43 | sum += inputBuffer[inputIndex]; 44 | num++; 45 | inputIndex++; 46 | } 47 | outputFrame[outputIndex] = sum / num; 48 | outputIndex++; 49 | } 50 | 51 | postMessage(outputFrame); 52 | 53 | inputBuffer = inputBuffer.slice(inputIndex); 54 | } 55 | } 56 | 57 | function reset() { 58 | inputBuffer = []; 59 | } -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/bumblebee-workers/porcupine.js: -------------------------------------------------------------------------------- 1 | let Porcupine = (function () { 2 | /** 3 | * Binding for wake word detection object. It initializes the JS binding for WebAssembly module and exposes 4 | * a factory method for creating new instances of wake word engine. 5 | */ 6 | 7 | let initWasm = null; 8 | let releaseWasm = null; 9 | let processWasm = null; 10 | let sampleRate = null; 11 | let frameLength = null; 12 | let version = null; 13 | 14 | let porcupineModule = PorcupineModule(); 15 | porcupineModule.then(function(Module) { 16 | initWasm = Module.cwrap('pv_porcupine_wasm_init', 'number', ['number', 'number', 'number', 'number']); 17 | releaseWasm = Module.cwrap('pv_porcupine_wasm_delete', ['number']); 18 | processWasm = Module.cwrap('pv_porcupine_wasm_process', 'number', ['number', 'number']); 19 | sampleRate = Module.cwrap('pv_wasm_sample_rate', 'number', [])(); 20 | frameLength = Module.cwrap('pv_porcupine_wasm_frame_length', 'number', [])(); 21 | version = Module.cwrap('pv_porcupine_wasm_version', 'string', [])(); 22 | }); 23 | 24 | let isLoaded = function() { 25 | /** 26 | * Flag indicating if 'PorcupineModule' is loaded. .create() can only be called after loading is finished. 27 | */ 28 | return initWasm != null; 29 | }; 30 | 31 | let create = function (keywordIDs, sensitivities) { 32 | /** 33 | * Creates an instance of wake word detection engine (aka porcupine). Can be called only after .isLoaded() 34 | * returns true. 35 | * @param {Array} Array of keyword IDs. A keyword ID is the signature for a given phrase to be detected. Each 36 | * keyword ID should be stored as UInt8Array. 37 | * @param {Float32Array} Detection sensitivity. A higher sensitivity reduces miss rate at the cost of higher 38 | * false alarm rate. Sensitivity is a number within [0, 1]. 39 | * @returns An instance of wake word detection engine. 40 | */ 41 | let keywordIDSizes = Int32Array.from(keywordIDs.map(keywordID => keywordID.byteLength)); 42 | let keywordIDSizesPointer = porcupineModule._malloc(keywordIDSizes.byteLength); 43 | let keywordIDSizesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, keywordIDSizesPointer, keywordIDSizes.byteLength); 44 | keywordIDSizesBuffer.set(new Uint8Array(keywordIDSizes.buffer)); 45 | 46 | let keywordIDPointers = Uint32Array.from(keywordIDs.map(keywordID => { 47 | let heapPointer = porcupineModule._malloc(keywordID.byteLength); 48 | let heapBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, heapPointer, keywordID.byteLength); 49 | heapBuffer.set(keywordID); 50 | return heapPointer; 51 | })); 52 | 53 | let keywordIDPointersPointer = porcupineModule._malloc(keywordIDPointers.byteLength); 54 | let keywordIDPointersBuffer = new Uint8Array( 55 | porcupineModule.HEAPU8.buffer, 56 | keywordIDPointersPointer, 57 | keywordIDPointers.byteLength); 58 | keywordIDPointersBuffer.set(new Uint8Array(keywordIDPointers.buffer)); 59 | 60 | let sensitivitiesPointer = porcupineModule._malloc(sensitivities.byteLength); 61 | let sensitivitiesBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, sensitivitiesPointer, sensitivities.byteLength); 62 | sensitivitiesBuffer.set(new Uint8Array(sensitivities.buffer)); 63 | 64 | let handleWasm = initWasm( 65 | keywordIDs.length, 66 | keywordIDSizesPointer, 67 | keywordIDPointersPointer, 68 | sensitivitiesPointer); 69 | if (handleWasm === 0) { 70 | throw new Error("failed to initialize porcupine."); 71 | } 72 | 73 | let pcmWasmPointer = porcupineModule._malloc(frameLength * 2); 74 | 75 | let release = function () { 76 | /** 77 | * Releases resources acquired by WebAssembly module. 78 | */ 79 | 80 | releaseWasm(handleWasm); 81 | porcupineModule._free(pcmWasmPointer); 82 | }; 83 | 84 | let process = function (pcmInt16Array) { 85 | /** 86 | * Processes a frame of audio. The required sample rate can be retrieved from .sampleRate and the length of 87 | * frame (number of samples within frame) can be retrieved from .frameLength. 88 | * @param {Int16Array} A frame of audio with properties described above. 89 | * @returns {Number} Index of detected keyword (phrase). When no keyword is detected it returns -1. 90 | */ 91 | 92 | let pcmWasmBuffer = new Uint8Array(porcupineModule.HEAPU8.buffer, pcmWasmPointer, pcmInt16Array.byteLength); 93 | pcmWasmBuffer.set(new Uint8Array(pcmInt16Array.buffer)); 94 | 95 | let keyword_index = processWasm(handleWasm, pcmWasmPointer); 96 | if (keyword_index === -2) { 97 | throw new Error("porcupine failed to process audio"); 98 | } 99 | 100 | return keyword_index; 101 | }; 102 | 103 | return { 104 | release: release, 105 | process: process, 106 | sampleRate: sampleRate, 107 | frameLength: frameLength, 108 | version: version 109 | } 110 | }; 111 | 112 | return {isLoaded: isLoaded, create: create} 113 | })(); 114 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/bumblebee-workers/porcupine_worker.js: -------------------------------------------------------------------------------- 1 | importScripts("pv_porcupine.js"); 2 | importScripts("porcupine.js"); 3 | 4 | onmessage = function (e) { 5 | switch (e.data.command) { 6 | case "init": 7 | init(e.data.keywordIDs, e.data.sensitivities); 8 | break; 9 | case "process": 10 | process(e.data.inputFrame); 11 | break; 12 | case "release": 13 | release(); 14 | break; 15 | } 16 | }; 17 | 18 | let keywordIDArray; 19 | let keywords; 20 | let sensitivities; 21 | 22 | let porcupine = null; 23 | 24 | function init(keywordIDs, _sensitivities_) { 25 | keywordIDArray = Object.values(keywordIDs); 26 | keywords = Object.keys(keywordIDs); 27 | sensitivities = _sensitivities_; 28 | 29 | if (Porcupine.isLoaded()) { 30 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 31 | } 32 | } 33 | 34 | function process(inputFrame) { 35 | if (porcupine == null && Porcupine.isLoaded()) { 36 | porcupine = Porcupine.create(keywordIDArray, sensitivities); 37 | } else if (porcupine != null) { 38 | let keywordIndex = porcupine.process(inputFrame); 39 | postMessage({keyword: keywordIndex === -1 ? null : keywords[keywordIndex]}); 40 | } 41 | } 42 | 43 | function release() { 44 | if (porcupine !== null) { 45 | porcupine.release(); 46 | } 47 | 48 | porcupine = null; 49 | } 50 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/bumblebee-workers/pv_porcupine.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-hotword-example/public/bumblebee-workers/pv_porcupine.wasm -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-hotword-example/public/favicon.ico -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 15 | 16 | 25 | BumbleBee + DeepSpeech Test 26 | 27 | 28 | 29 | 30 |
    31 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/sounds/bumblebee-off.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-hotword-example/public/sounds/bumblebee-off.mp3 -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/public/sounds/bumblebee-on.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/not_working/web-hotword-example/public/sounds/bumblebee-on.mp3 -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const socketIO = require('socket.io'); 3 | 4 | const Jaxcore = require('jaxcore'); 5 | const jaxcore = new Jaxcore(); 6 | 7 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 8 | 9 | const SERVER_PORT = 4000; // websocket server port 10 | 11 | function startSocketServer(deepspeech) { 12 | const app = http.createServer(function (req, res) { 13 | res.writeHead(200); 14 | res.write('web-basic-example'); 15 | res.end(); 16 | }); 17 | 18 | const io = socketIO(app, {}); 19 | io.set('origins', '*:*'); 20 | 21 | io.on('connection', function (socket) { 22 | console.log('client connected'); 23 | 24 | socket.once('disconnect', () => { 25 | console.log('client disconnected'); 26 | }); 27 | 28 | deepspeech.on('recognize', (text, stats) => { 29 | socket.emit('recognize', text, stats); 30 | }); 31 | 32 | socket.on('stream-data', function (data) { 33 | deepspeech.streamData(data); 34 | }); 35 | socket.on('stream-end', function () { 36 | deepspeech.streamEnd(); 37 | }); 38 | socket.on('stream-reset', function () { 39 | deepspeech.streamReset(); 40 | }); 41 | }); 42 | 43 | app.listen(SERVER_PORT, 'localhost', () => { 44 | console.log('Socket server listening on:', SERVER_PORT); 45 | }); 46 | } 47 | 48 | // start the speech adapter (pay attention to the deepspeech modelPath location) 49 | jaxcore.startService('deepspeech', { 50 | modelName: 'english', 51 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model 52 | silenceThreshold: 200, 53 | vadMode: 'VERY_AGGRESSIVE', 54 | debug: true 55 | }, function(err, deepspeech) { 56 | console.log('deepspeech service ready', typeof deepspeech); 57 | startSocketServer(deepspeech); 58 | }); 59 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 20px; 3 | line-height: 1.5em; 4 | } 5 | select, button { 6 | font-size: 20px; 7 | } 8 | -------------------------------------------------------------------------------- /examples/not_working/web-hotword-example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import BumbleBeeDeepSpeechApp from './BumbleBeeDeepSpeechApp'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /examples/old/node-hello-world/start.js: -------------------------------------------------------------------------------- 1 | // import Jaxcore and create an instance 2 | const Jaxcore = require('jaxcore'); 3 | const {Adapter} = require('jaxcore'); 4 | const jaxcore = new Jaxcore(); 5 | 6 | // import the Jaxcore Speech plugin 7 | const SpeechPlugin = require('../../index'); // or use require('jaxcore-speech'); 8 | jaxcore.addPlugin(SpeechPlugin); 9 | 10 | // import spawn to call "say" command line on MacOSX 11 | const {spawn, spawnSync} = require('child_process'); 12 | 13 | function say(text, sync) { 14 | if (process.platform === 'darwin') { 15 | if (sync) spawnSync('say', [JSON.stringify(text)]); 16 | else spawn('say', [JSON.stringify(text)]); 17 | } 18 | } 19 | 20 | // create a custom Jaxcore adapter for handling speech 21 | class HelloWorldAdapter extends Adapter { 22 | constructor(store, config, theme, devices, services) { 23 | super(store, config, theme, devices, services); 24 | const {speech} = devices; 25 | 26 | this.addEvents(speech, { 27 | recognize: function (text, stats) { 28 | console.log('speech recognized:', text); 29 | 30 | /* YOUR CODE GOES HERE */ 31 | 32 | if (text === 'hello world') { 33 | console.log('YOU SAID HELLO WORLD!!!'); 34 | 35 | // stop recording before using speech synthesis 36 | speech.stopContinuous(); 37 | 38 | // use speech synthesis to respond 39 | say('hello world'); 40 | 41 | // wait 2 seconds to let "say" complete before turning on continuous recording 42 | setTimeout(function() { 43 | speech.startContinuous(); 44 | },1500); 45 | } 46 | 47 | } 48 | }); 49 | 50 | // start recording continuously 51 | say('recording is now on', true); 52 | speech.startContinuous(); 53 | } 54 | } 55 | 56 | // add the adapter to Jaxcore 57 | jaxcore.addAdapter('helloworld', HelloWorldAdapter); 58 | 59 | jaxcore.on('service-connected', function(type, service) { 60 | if (type === 'speech') { 61 | // when the speech service is ready, launch the adapter 62 | const speech = service; 63 | jaxcore.launchAdapter(speech, 'helloworld'); 64 | } 65 | }); 66 | 67 | // start the speech adapter (pay attention to the deepspeech modelPath location) 68 | jaxcore.startService('speech', null, null, { 69 | modelName: 'english', 70 | modelPath: __dirname + '/../../deepspeech-0.6.0-models' 71 | }, function(err, speech) { 72 | console.log('speech service ready', typeof speech); 73 | }); -------------------------------------------------------------------------------- /examples/old/node-microphone/continuous.js: -------------------------------------------------------------------------------- 1 | let Speech = require('../../lib/speech'); 2 | 3 | let speech = new Speech({ 4 | models: { 5 | english: { 6 | path: __dirname + '/../../deepspeech-0.6.0-models' 7 | } 8 | } 9 | }); 10 | 11 | speech.on('recognize', function (text) { 12 | console.log('Recognized Text:', text); 13 | }); 14 | 15 | speech.on('start-continuous', function () { 16 | console.log('start-continuous'); 17 | }); 18 | 19 | speech.on('stop-continuous', function () { 20 | console.log('stop-continuous'); 21 | }); 22 | 23 | const readline = require('readline').createInterface({ 24 | input: process.stdin, 25 | output: process.stdout 26 | }); 27 | 28 | function continuousLoop() { 29 | console.log('\nPress Ctrl-C to exit at any time.'); 30 | 31 | readline.question('\nPress ENTER to start continuous recording.\n', (name) => { 32 | 33 | readline.question('Press ENTER to stop.\n', (name) => { 34 | 35 | console.log('Stopping continuous recording.'); 36 | 37 | speech.stopContinuous(); 38 | 39 | setTimeout(continuousLoop, 1000); 40 | }); 41 | 42 | // todo: fix continuousRecorder already started 43 | speech.startContinuous(); 44 | 45 | }); 46 | } 47 | 48 | process.stdin.resume(); 49 | 50 | continuousLoop(); 51 | -------------------------------------------------------------------------------- /examples/old/node-microphone/momentary.js: -------------------------------------------------------------------------------- 1 | let Speech = require('../../lib/speech'); 2 | 3 | let speech = new Speech({ 4 | models: { 5 | english: { 6 | path: __dirname + '/../../deepspeech-0.6.0-models' 7 | } 8 | } 9 | }); 10 | 11 | const readline = require('readline').createInterface({ 12 | input: process.stdin, 13 | output: process.stdout 14 | }); 15 | 16 | function startConsoleLoop() { 17 | console.log('\nPress Ctrl-C to exit at any time.'); 18 | 19 | readline.question('\nPress ENTER to start recording.\n', (name) => { 20 | 21 | const onRecognize = function (text) { 22 | speech.removeListener('recognize', onRecognize); 23 | console.log('Recognized as:', text); 24 | startConsoleLoop(); 25 | }; 26 | 27 | readline.question('Press ENTER to stop.\n', (name) => { 28 | speech.stop(); 29 | console.log('Stopped recording.'); 30 | }); 31 | 32 | speech.on('recognize', onRecognize); 33 | 34 | speech.start(); 35 | }); 36 | } 37 | 38 | process.stdin.resume(); 39 | 40 | startConsoleLoop(); 41 | -------------------------------------------------------------------------------- /examples/old/node-mouse-control/README.md: -------------------------------------------------------------------------------- 1 | ## Mouse Control speech adapter 2 | 3 | Using this test script you can control your computer mouse with your voice: 4 | 5 | ``` 6 | node start.js 7 | ``` 8 | 9 | Available voice commands are: 10 | 11 | - "left click" // clicks left mouse button 12 | - "right click" // clicks right mouse button 13 | - "middle click" // clicks middle mouse button 14 | - "mouse up 100" // moves mouse up 100 pixels 15 | - "mouse down 100" // moves mouse down 100 pixels 16 | - "mouse left 100" // moves mouse left 100 pixels 17 | - "mouse right 100" // moves mouse right 100 pixels 18 | - "page down" // presses page down key 19 | - "page up" // presses page down key 20 | - "up" // presses up arrow key 21 | - "down" // presses down arrow key 22 | - "left" // presses left arrow key 23 | - "right" // presses right arrow key 24 | - "scroll down" 25 | - "scroll down 100" // scrolls down 100 pixels 26 | - "scroll up" 27 | - "scroll up 100" // scrolls up 100 pixels 28 | 29 | -------------------------------------------------------------------------------- /examples/old/node-speechadapter/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/old/node-speechadapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-wakeword-example", 3 | "version": "0.0.2", 4 | "description": "uses bumblebee as wake word to activate deepspeech", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "jaxcore-say-node": "0.0.6", 16 | "speaker": "^0.5.1", 17 | "wav": "^1.0.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/old/node-speechadapter/start.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const Adapter = Jaxcore.Adapter; 3 | const jaxcore = new Jaxcore(); 4 | jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 5 | 6 | jaxcore.addPlugin(require('bumblebee-hotword-node')); 7 | 8 | // const BumbleBee = require('bumblebee-hotword-node'); 9 | // const bumblebee = new BumbleBee(); 10 | // bumblebee.setHotword('bumblebee'); 11 | 12 | const MODEL_PATH = process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models'; // path to deepspeech model 13 | 14 | class SpeechConsoleAdapter extends Adapter { 15 | // static getDefaultState() { 16 | // return { 17 | // }; 18 | // } 19 | // 20 | constructor(store, config, theme, devices, services) { 21 | super(store, config, theme, devices, services); 22 | 23 | // const {deepspeech} = services; 24 | const {deepspeech, bumblebeeNode} = services; 25 | console.log('CREATED SpeechConsoleAdapter', deepspeech); 26 | 27 | bumblebeeNode.setHotword('bumblebee'); 28 | 29 | // process.exit(); 30 | 31 | // const {speech} = devices; 32 | // const {keyboard, mouse, scroll} = services; 33 | 34 | this.addEvents(deepspeech, { 35 | recognize: function (text, stats) { 36 | this.log('SpeechConsoleAdapter recognize', text, stats); 37 | } 38 | }); 39 | 40 | this.addEvents(bumblebeeNode, { 41 | hotword: function(hotword) { 42 | console.log('hotword detected', hotword); 43 | }, 44 | data: function (data) { 45 | deepspeech.streamData(data); 46 | } 47 | }); 48 | 49 | } 50 | 51 | static getServicesConfig(adapterConfig) { 52 | console.log('getServicesConfig', adapterConfig); 53 | return { 54 | deepspeech: adapterConfig.profile.services.deepspeech 55 | }; 56 | } 57 | } 58 | 59 | jaxcore.addAdapter('speech-console', SpeechConsoleAdapter); 60 | 61 | // jaxcore.defineService('DeepSpeech', { 62 | // 63 | // }); 64 | jaxcore.defineAdapter('Speech Console', { 65 | adapterType: 'speech-console', 66 | // deviceType: 'speech', 67 | services: { 68 | bumblebeeNode: true, 69 | deepspeech: { 70 | modelName: 'english', 71 | modelPath: MODEL_PATH, 72 | silenceThreshold: 200, // how many milliseconds of silence before processing the audio 73 | vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 74 | debug: 'true' 75 | } 76 | } 77 | }); 78 | 79 | // jaxcore.on('spin-connected', function(spin) { 80 | // console.log('connected', spin.id); 81 | // 82 | // jaxcore.connectAdapter(spin, 'mouse-default'); 83 | // }); 84 | // 85 | // jaxcore.startDevice('spin'); 86 | 87 | jaxcore.connectAdapter(null, 'Speech Console'); 88 | 89 | // jaxcore.startService('deepspeech', { 90 | // modelName: 'english', 91 | // modelPath: MODEL_PATH, 92 | // silenceThreshold: 200, // how many milliseconds of silence before processing the audio 93 | // vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 94 | // debug: 'true' 95 | // }, function(err, deepspeech) { 96 | // 97 | // deepspeech.on('recognize', function(text) { 98 | // console.log('recognize', text); 99 | // }); 100 | // 101 | // bumblebee.on('data', function(data) { 102 | // // stream microphone data to deepspeech 103 | // deepspeech.streamData(data); 104 | // }); 105 | // 106 | // // bumblebee start the microphone 107 | // bumblebee.start(); 108 | // 109 | // 110 | // jaxcore.connectAdapter(null, 'Speech Console'); 111 | // }); 112 | -------------------------------------------------------------------------------- /examples/old/node-voiceassistant/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/old/node-voiceassistant/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript Voice Assistant Toolbox 2 | 3 | This is a NodeJS example which combines all the key speech technologies necessary to write a voice assistant in JavaScript. 4 | 5 | To create a voice assistant, the following speech technologies are required: 6 | 7 | - speech-to-text 8 | - text-to-speech 9 | - hotword detection 10 | - voice activity detection 11 | 12 | This example combines libraries to accomplish these tasks allowing JavaScript developers to easily 13 | create voice controlled applications. 14 | Control devices in your home or create speech-based utilities and applications of any kind. 15 | And it's all open source with 100% privacy. 16 | 17 | The libraries used are: 18 | 19 | - Speech Recognition: 20 | - [DeepSpeech](https://github.com/mozilla/DeepSpeech) - TensorFlow based speech-to-text engine 21 | - [Jaxcore DeepSpeech Plugin](https://github.com/jaxcore/deepspeech-plugin) - deepspeech background process launcher 22 | - [Node VAD](https://github.com/snirpo/node-vad) - voice activity detection 23 | - Wake Word Detection: 24 | - [BumbleBee Hotword](https://github.com/jaxcore/bumblebee-hotword-node) - hotword detection based on [Porcupine](https://github.com/Picovoice/porcupine) 25 | - Speech Synthesis: 26 | - [Jaxcore Say](https://github.com/jaxcore/jaxcore-say-node) - text-to-speech based on [mEspeak.js](https://www.masswerk.at/mespeak/) 27 | 28 | ### Usage 29 | 30 | Follow the instructions to install the example on your computer. Everything, including the DeepSpeech 31 | speech recognition system, runs locally. 32 | 33 | Make sure a microphone is active on the computer and speakers are turned on. Attempt to activate 34 | speech recognition by saying "BumbleBee". You should hear a "speech recognition enabled" from the 35 | speakers. Any words spoken will be processed to text, then spoken back using speech synthesis. 36 | 37 | Have Fun! 38 | 39 | --- 40 | 41 | ### Installation 42 | 43 | ``` 44 | git clone https://github.com/jaxcore/deepspeech-plugin 45 | cd deepspeech-plugin 46 | npm install 47 | ``` 48 | 49 | #### Download DeepSpeech Pre-Trained english model: 50 | 51 | If the DeepSpeech models have not previously been downloaded, do so now (beware this is a large download >1.8GB): 52 | 53 | ``` 54 | wget https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz 55 | tar xfvz deepspeech-0.6.0-models.tar.gz 56 | rm deepspeech-0.6.0-models.tar.gz 57 | ``` 58 | 59 | Go do the voice assistant example directory: 60 | 61 | ``` 62 | cd examples/node-voiceassistant 63 | ``` 64 | 65 | Install: 66 | 67 | ``` 68 | npm install 69 | npm install speaker 70 | ``` 71 | 72 | Mac OSX users will have to install an alternative speaker backend: 73 | 74 | ``` 75 | npm install speaker --mpg123-backend=openal --no-save 76 | ``` 77 | 78 | Start the server: 79 | 80 | ``` 81 | node start.js 82 | ``` 83 | 84 | #### Alternative deepspeech model directory 85 | 86 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 87 | 88 | ``` 89 | DEEPSPEECH_MODEL=/path/to/deepspeech-models node start.js 90 | ``` -------------------------------------------------------------------------------- /examples/old/node-voiceassistant/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-wakeword-example", 3 | "version": "0.0.2", 4 | "description": "uses bumblebee as wake word to activate deepspeech", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.4", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-deepspeech-plugin": "0.0.6", 15 | "jaxcore-say-node": "0.0.6", 16 | "speaker": "^0.5.1", 17 | "wav": "^1.0.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/old/node-voiceassistant/start.js: -------------------------------------------------------------------------------- 1 | // use control system (jaxcore) 2 | const Jaxcore = require('jaxcore'); 3 | const jaxcore = new Jaxcore(); 4 | 5 | // use jaxcore deepspeech service (launches deepspeech in background process) 6 | const DeepSpeechService = require('jaxcore-deepspeech-plugin'); 7 | jaxcore.addPlugin(DeepSpeechService); 8 | 9 | // load hotword detection module (bumblebee-hotword-node) 10 | const BumbleBee = require('bumblebee-hotword-node'); 11 | const bumblebee = new BumbleBee(); 12 | bumblebee.addHotword('bumblebee'); 13 | bumblebee.setHotword('bumblebee'); 14 | 15 | // load text-to-speech module (jaxcore-say-node) 16 | const Say = require('jaxcore-say-node'); 17 | Say.speaker = require('speaker'); 18 | 19 | const voice = new Say({ language: 'en-us', profile: 'Jack' }); 20 | 21 | // path to deepspeech model 22 | const MODEL_PATH = process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.6.0-models'; 23 | 24 | let speechRecognitionActive = false; 25 | 26 | jaxcore.startService('deepspeech', { 27 | modelName: 'english', 28 | modelPath: MODEL_PATH, 29 | silenceThreshold: 200, // how many milliseconds of silence before processing the audio 30 | vadMode: 'VERY_AGGRESSIVE', // options are: 'NORMAL', 'LOW_BITRATE', 'AGGRESSIVE', 'VERY_AGGRESSIVE' 31 | debug: 'true' 32 | }, function(err, deepspeech) { 33 | 34 | deepspeech.on('recognize', (text, stats) => { 35 | console.log('Speech recognition result:', text); 36 | 37 | speechRecognitionActive = false; // disable recognition while using text-to-speech 38 | voice.say(text).then(() => { 39 | // delay a bit and reset the deepspeech buffer before re-enabling recognition 40 | setTimeout(function() { 41 | deepspeech.streamReset(); 42 | speechRecognitionActive = true; 43 | },200); 44 | }); 45 | }); 46 | 47 | bumblebee.on('hotword', function(hotword) { 48 | if (speechRecognitionActive) { 49 | stopRecognition(); 50 | } 51 | else if (!speechRecognitionActive) { 52 | startRecognition(); 53 | } 54 | deepspeech.streamReset(); // reset to ignore speech recognition of the hotword that was spoken 55 | }); 56 | 57 | bumblebee.on('data', function(data) { 58 | if (speechRecognitionActive) { 59 | deepspeech.streamData(data); 60 | } 61 | }); 62 | 63 | bumblebee.start(); 64 | 65 | console.log('\nStart speech recognition by saying:', Object.keys(bumblebee.hotwords)); 66 | }); 67 | 68 | function stopRecognition() { 69 | console.log('\nStart speech recognition by saying:', Object.keys(bumblebee.hotwords)); 70 | 71 | console.log('Speech recognition disabled'); 72 | speechRecognitionActive = false; 73 | 74 | voice.say("speech recognition disabled"); 75 | } 76 | 77 | function startRecognition() { 78 | console.log('Stop speech recognition by saying:', Object.keys(bumblebee.hotwords)); 79 | 80 | console.log('Speech recognition enabled'); 81 | voice.say("speech recognition enabled").then(() => { 82 | speechRecognitionActive = true; 83 | }); 84 | } 85 | -------------------------------------------------------------------------------- /examples/old/web-demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/old/web-demo/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /examples/old/web-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-demo", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "react": "^16.8.3", 6 | "react-dom": "^16.8.3", 7 | "react-scripts": "2.1.5", 8 | "words-to-numbers": "^1.5.1", 9 | "jaxcore-client": "^0.0.3" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test", 15 | "eject": "react-scripts eject" 16 | }, 17 | "eslintConfig": { 18 | "extends": "react-app" 19 | }, 20 | "browserslist": [ 21 | ">0.2%", 22 | "not dead", 23 | "not ie <= 11", 24 | "not op_mini all" 25 | ], 26 | "homepage": ".", 27 | "license": "MIT" 28 | } 29 | -------------------------------------------------------------------------------- /examples/old/web-demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-demo/public/favicon.ico -------------------------------------------------------------------------------- /examples/old/web-demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 15 | 16 | 25 | Jaxcore Listen 26 | 27 | 28 | 29 |
    30 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/old/web-demo/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /examples/old/web-demo/src/ListenApp.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/old/web-demo/src/index.css: -------------------------------------------------------------------------------- 1 | button { 2 | font-size: 20px; 3 | margin:0.5em; 4 | } -------------------------------------------------------------------------------- /examples/old/web-demo/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import ListenApp from './ListenApp'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: http://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /examples/old/web-demo/src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read http://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit http://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See http://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl) 104 | .then(response => { 105 | // Ensure service worker exists, and that we really are getting a JS file. 106 | const contentType = response.headers.get('content-type'); 107 | if ( 108 | response.status === 404 || 109 | (contentType != null && contentType.indexOf('javascript') === -1) 110 | ) { 111 | // No service worker found. Probably a different app. Reload the page. 112 | navigator.serviceWorker.ready.then(registration => { 113 | registration.unregister().then(() => { 114 | window.location.reload(); 115 | }); 116 | }); 117 | } else { 118 | // Service worker found. Proceed as normal. 119 | registerValidSW(swUrl, config); 120 | } 121 | }) 122 | .catch(() => { 123 | console.log( 124 | 'No internet connection found. App is running in offline mode.' 125 | ); 126 | }); 127 | } 128 | 129 | export function unregister() { 130 | if ('serviceWorker' in navigator) { 131 | navigator.serviceWorker.ready.then(registration => { 132 | registration.unregister(); 133 | }); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-vocab-tester", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "bumblebee-hotword": "^0.0.1", 6 | "jaxcore-client": "^0.0.3", 7 | "jaxcore-speak": "^0.0.2", 8 | "react": "^16.8.4", 9 | "react-dom": "^16.8.4", 10 | "react-scripts": "2.1.8", 11 | "words-to-numbers": "^1.5.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": [ 23 | ">0.2%", 24 | "not dead", 25 | "not ie <= 11", 26 | "not op_mini all" 27 | ], 28 | "homepage": ".", 29 | "license": "MIT" 30 | } 31 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/ding-end.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-vocab-tester/public/ding-end.wav -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/ding-start.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-vocab-tester/public/ding-start.wav -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/end.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-vocab-tester/public/end.wav -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-vocab-tester/public/favicon.ico -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 15 | 16 | 25 | Vocabulary Tester 26 | 27 | 28 | 29 |
    30 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/public/pv_porcupine.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaxcore/deepspeech-plugin/3e4978bc15d4fd697834b20f5b986aea46e3e046/examples/old/web-vocab-tester/public/pv_porcupine.wasm -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/VocabApp.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import InterpreterApp from './InterpreterApp'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 5 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | margin-top: 95px; 10 | } 11 | 12 | div.panel { 13 | position: fixed; 14 | top:0; 15 | left:0; 16 | width: 100%; 17 | height:70px; 18 | background: #fff; 19 | border-bottom: 2px solid #333; 20 | font-size: 25px; 21 | line-height:32px; 22 | } 23 | 24 | table { 25 | width: 100%; 26 | } 27 | table, td { 28 | border: 1px solid #ccc; 29 | border-spacing: 0; 30 | } 31 | 32 | td, th { 33 | padding: 4px; 34 | } 35 | 36 | .dec, .hex, .char { 37 | width: 70px; 38 | } 39 | th.dec, th.hex, th.char { 40 | width: 70px; 41 | display: inline-block; 42 | } 43 | 44 | tbody.header { 45 | position:fixed; 46 | top:71px; 47 | left:0; 48 | width: 100%; 49 | background: #000; 50 | } 51 | 52 | th { 53 | font-weight: normal; 54 | border: 1px solid #000; 55 | background: #000; 56 | color: #fff; 57 | text-align: left; 58 | text-indent:1em; 59 | } 60 | 61 | tr.voiceSelected td { 62 | background: #00AA00; 63 | color: #fff; 64 | } 65 | tr.mouseSelected td { 66 | background: #DDD; 67 | color: #000; 68 | } 69 | 70 | td.char, td.dec { 71 | text-align:center; 72 | } 73 | 74 | tr.voiceSelected TD A { 75 | color: #FFF; 76 | } 77 | 78 | #speak { 79 | /*background:red;*/ 80 | position: absolute; 81 | right:70px; 82 | top:0; 83 | } 84 | #listen { 85 | /*background:blue;*/ 86 | position: absolute; 87 | right:0; 88 | top:0; 89 | } 90 | 91 | select.selectedInterpreter { 92 | 93 | } 94 | div.panelOptions { 95 | position: absolute; 96 | right: 150px; 97 | top: 0; 98 | } 99 | div.panelOptions div { 100 | float:right; 101 | clear: both; 102 | font-size: 13px; 103 | /*line-height: 1.6em;*/ 104 | } 105 | div.panelOptions div * { 106 | /*vertical-align: top;*/ 107 | } -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import VocabApp from './VocabApp'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/interpreters/ascii.js: -------------------------------------------------------------------------------- 1 | import asciiData from './ascii.json'; 2 | 3 | function sortWordLength(a, b) { 4 | if (a[0].length === b[0].length) { 5 | return parseInt(a[1]) > parseInt(b[1]); 6 | } 7 | return a[0].length < b[0].length ? 1 : -1; 8 | } 9 | 10 | function loadAscii() { 11 | let asciiWords = []; 12 | 13 | let dec, ch; 14 | 15 | var words; 16 | 17 | // todo: improve performance by converting all single words to a hash 18 | 19 | for (dec in asciiData) { 20 | ch = asciiData[dec][0]; 21 | words = asciiData[dec][1]; 22 | if (!words) { 23 | asciiData[dec][1] = []; 24 | words = []; 25 | } 26 | 27 | dec = parseInt(dec); 28 | 29 | if (dec >= 65 && dec <= 90) { // A-Z 30 | let lch = ch.toLowerCase(); 31 | let letter = dec + 32; 32 | let letterwords = asciiData[letter][1]; 33 | if (!letterwords) { 34 | asciiData[letter][1] = []; 35 | letterwords = [lch]; 36 | } 37 | 38 | letterwords.forEach((lw) => { 39 | words.unshift("upper case " + lw); 40 | asciiData[dec][1].push(words[0]); 41 | words.unshift("capital " + lw); 42 | asciiData[dec][1].push(words[0]); 43 | }); 44 | 45 | // words = words.concat(letterwords); 46 | // words.unshift("uppercase " + lch); 47 | words.unshift("upper case " + lch); 48 | words.unshift("capital " + lch); 49 | 50 | 51 | 52 | } else if (dec >= 97 && dec <= 122) { // a-z 53 | // words.unshift("lowercase " + ch); 54 | words.unshift("letter " + ch); 55 | words.unshift("lower case " + ch); 56 | words.unshift(ch); 57 | } 58 | 59 | if (words.length === 0) { 60 | debugger; 61 | asciiWords.push([ch, dec]); 62 | } else { 63 | for (let w=0;w parseInt(b[1]); 6 | } 7 | return a[0].length < b[0].length ? 1 : -1; 8 | } 9 | 10 | let chessWords = []; 11 | 12 | function loadChess() { 13 | 14 | for (let key in chessData) { 15 | let words = chessData[key]; 16 | words.forEach(word => { 17 | chessWords.push([word,key]); 18 | }) 19 | } 20 | chessWords.sort(sortWordLength); 21 | 22 | 23 | const chessInterpreter = function(text, prevText, prevIndex, afterBefore) { 24 | let index = null; 25 | 26 | let w; 27 | let strIndex; 28 | 29 | for (let i = 0; i < chessWords.length; i++) { 30 | w = chessWords[i][0]; 31 | 32 | let same = false; 33 | if (text === w) { 34 | index = i; 35 | strIndex = 0; 36 | same = true; 37 | break; 38 | } else { 39 | let reg = new RegExp("^" + w + " | " + w + " | " + w + "$"); 40 | let m = text.match(reg); 41 | if (m) { 42 | index = i; 43 | strIndex = m.index; 44 | break; 45 | } 46 | } 47 | } 48 | if (index !== null) { 49 | let found = chessWords[index][0]; 50 | let key = chessWords[index][1]; 51 | // let ch = ascii[dec][0]; 52 | let before = text.substring(0, strIndex); 53 | let after = text.substring(strIndex + found.length + 1); 54 | let ret = []; //b,found,a]; 55 | 56 | console.log('found chess:', found); 57 | 58 | if (before) { 59 | let b = chessInterpreter(before, text, strIndex, 0); 60 | if (b) ret.push(b); 61 | } 62 | 63 | ret.push({ 64 | key, 65 | word: w, 66 | index: strIndex 67 | }); 68 | 69 | if (after) { 70 | let a = chessInterpreter(after, text, strIndex, 1); 71 | if (a) ret.push(a); 72 | } 73 | 74 | let r = ret.flat(); 75 | return r; 76 | } else { 77 | return; 78 | } 79 | }; 80 | 81 | 82 | 83 | return chessInterpreter; 84 | } 85 | 86 | const interpreter = loadChess(); 87 | 88 | export {chessData, chessWords}; 89 | 90 | export default interpreter; -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/interpreters/chess.json: -------------------------------------------------------------------------------- 1 | {"1":["one"],"2":["two","to"],"3":["three","tree","free","through"],"4":["four","for"],"5":["five","i've"],"6":["six","sex"],"7":["seven"],"8":["eight"],"a":["a","letter a","alpha","all the"],"b":["b","letter b","be","bravo"],"c":["c","letter c","sea","see","charlie","charles","charley","charl"],"d":["d","letter d","de","delta","dolt","dealt"],"e":["e","letter e","he","letter he"],"f":["f","letter f","if","ah","as","at","fox trot","fox to","of"],"g":["g","letter g","j","letter j","ja","ji","golf","go"],"h":["h","letter h","eh","age","each","hotel","potel","bach","ach","each"],"P":["pawn","pon","paw","pan","on","upon","tom"],"N":["knight","night","net","neat","might","knit"],"K":["king"],"Q":["queen","cream"],"R":["rook","ruck","rock","wreck"],"B":["bishop","ship"],"castle king side":["castle king side","castle king","castle kings","castle king so","cattle kings","at king's side"],"castle queen side":["castle queen side","castle queen","castle queens","castle queen so","cattle queens","castle quin","at queen's side","a quinsie"],"castle":["castle"],"en passant":["en passant","in person","un passant","and person","in person","and passant"],"promote":["promote"],"takeback":["take back"],"rotate":["rotate","rotate board","tate","rode hate","he wrote to","rotha","rose had"],"reverse board":["reverse board","flip board"],"select":["select"],"cancel":["cancel"],"menu":["menu","many","men you"],"resign":["resign","i resign","resigned","i resigned"],"draw":["draw","offer draw"],"yes":["yes","okay","alright","all right"],"no":["no"],"accept":["accept","except"],"decline":["decline"],"forward":["forward"],"reverse":["reverse"],"port":["port"],"starboard":["starboard","star board","star word","starward","star bore"],"left":["left","let","laughed","laugh"],"right":["right"],"up":["up"],"down":["down"],"next":["next","not","net"],"previous":["previous"],"takes":["takes","take"],"captures":["captures","capture"],"help":["help","show help"],"new game":["new game"],"save game":["save game"],"load game":["load game"],"pause":["pause"],"the":["the"]} -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/interpreters/datetime.js: -------------------------------------------------------------------------------- 1 | // todo: this is not done yet 2 | 3 | 4 | import datetimeData from './datetime.json'; 5 | import wordsToNumbers from 'words-to-numbers'; 6 | 7 | function sortWordLength(a, b) { 8 | if (a[0].length === b[0].length) { 9 | return 0; //parseInt(a[1]) > parseInt(b[1]); 10 | } 11 | return a[0].length < b[0].length ? 1 : -1; 12 | } 13 | 14 | const datetimeWords = []; 15 | 16 | 17 | 18 | function replacements(text) { 19 | let index = null; 20 | let w; 21 | let strIndex; 22 | 23 | for (let i = 0; i < datetimeWords.length; i++) { 24 | w = datetimeWords[i][0]; 25 | 26 | let same = false; 27 | if (text === w) { 28 | index = i; 29 | strIndex = 0; 30 | same = true; 31 | break; 32 | } else { 33 | let reg = new RegExp("^" + w + " | " + w + " | " + w + "$"); 34 | let m = text.match(reg); 35 | if (m) { 36 | index = i; 37 | strIndex = m.index; 38 | break; 39 | } 40 | } 41 | } 42 | if (index !== null) { 43 | let found = datetimeWords[index][0]; 44 | let key = datetimeWords[index][1]; 45 | // let ch = ascii[dec][0]; 46 | let before = text.substring(0, strIndex); 47 | let after = text.substring(strIndex + found.length + 1); 48 | let ret = []; //b,found,a]; 49 | 50 | console.log('found datetime:', found); 51 | 52 | if (before) { 53 | let b = replacements(before); 54 | if (b) ret.push(b); 55 | } 56 | 57 | ret.push(key); 58 | 59 | if (after) { 60 | let a = replacements(after); 61 | if (a) ret.push(a); 62 | } 63 | let r = ret.flat(); 64 | return r; 65 | } else { 66 | return [text.trim()]; 67 | } 68 | } 69 | 70 | const weekdayMap = {}; 71 | const weekdays = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday']; 72 | weekdays.forEach(function(m) { 73 | weekdayMap[m] = true; 74 | }); 75 | 76 | const monthMap = {}; 77 | const months = ['january','frebruary','march','april','may','june','july','august','september','october','november','december']; 78 | months.forEach(function(m) { 79 | monthMap[m] = true; 80 | }); 81 | 82 | function loadDatetime() { 83 | 84 | for (let key in datetimeData) { 85 | let words = datetimeData[key]; 86 | 87 | words.forEach(word => { 88 | datetimeWords.push([word,key]); 89 | }) 90 | } 91 | 92 | datetimeWords.sort(sortWordLength); 93 | 94 | const datetimeInterpreter = function(text) { 95 | let keys = replacements(text); 96 | console.log('orig', keys); 97 | 98 | // keys = keys.map(function(key) { 99 | // if (typeof key === 'string' && /[0-9]+/.test(key)) { 100 | // return { 101 | // month: months.indexOf(key) 102 | // }; 103 | // } 104 | // return key; 105 | // }); 106 | // console.log('months', keys); 107 | 108 | keys = keys.map(wordsToNumbers); 109 | console.log('numbers', keys); 110 | 111 | keys = keys.map(function(key) { 112 | if (key.indexOf(' ')) { 113 | return key.split(' '); 114 | } 115 | return key; 116 | }).flat(); 117 | 118 | keys = keys.map(function(key) { 119 | if (/[0-9]+/.test(key)) { 120 | return parseInt(key); 121 | } 122 | return key; 123 | }); 124 | 125 | keys = keys.map(function(key) { 126 | if (typeof key === 'string' && key in monthMap) { 127 | return { 128 | month: months.indexOf(key) 129 | }; 130 | } 131 | return key; 132 | }); 133 | console.log('months', keys); 134 | 135 | keys = keys.map(function(key) { 136 | if (typeof key === 'string' && key in weekdayMap) { 137 | return { 138 | weekday: weekdays.indexOf(key) 139 | }; 140 | } 141 | return key; 142 | }); 143 | console.log('weekdays', keys); 144 | 145 | // debugger; 146 | return new Date(); 147 | }; 148 | 149 | return datetimeInterpreter; 150 | } 151 | 152 | const interpreter = loadDatetime(); 153 | 154 | interpreter("thursday he pro first twenty nineteen at ten thirty five p m"); 155 | 156 | export {datetimeData, datetimeWords}; 157 | 158 | export default interpreter; -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/interpreters/datetime.json: -------------------------------------------------------------------------------- 1 | {"april":["a roll","he pro"],"october":["taber","tiber"],"tuesday":["to stay"],"wednesday":["when stay"],"tomorrow":["to morrow"],"today":["to day"],"AM":["a m"],"PM":["p m"],"two":["to"],"three":["tree","free","through"],"four":["for"],"five":["i've"],"six":["sex"]} -------------------------------------------------------------------------------- /examples/old/web-vocab-tester/src/interpreters/index.js: -------------------------------------------------------------------------------- 1 | import ascii, {asciiData} from './ascii.js'; 2 | import chess, {chessData} from './chess.js'; 3 | import datetime, {datetimeData} from './datetime.js'; 4 | 5 | const interpreterData = { 6 | ascii: asciiData, 7 | chess: chessData, 8 | datetime: datetimeData 9 | }; 10 | 11 | export {interpreterData}; 12 | 13 | const interpreters = { 14 | ascii, 15 | chess, 16 | datetime 17 | }; 18 | 19 | export default interpreters; -------------------------------------------------------------------------------- /examples/voice-assistant-toolbox/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /deepspeech-* 5 | /deepspeech-*/* 6 | /node_modules 7 | /.pnp 8 | .pnp.js 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /examples/voice-assistant-toolbox/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript Voice Assistant Toolbox 2 | 3 | 4 | ### Usage 5 | 6 | Follow the instructions to install the example on your computer. Everything, including the DeepSpeech 7 | speech recognition system, runs locally. 8 | 9 | Make sure a microphone is active on the computer and speakers are turned on. Attempt to activate 10 | speech recognition by saying "BumbleBee". You should hear a "speech recognition enabled" from the 11 | speakers. Any words spoken will be processed to text, then spoken back using speech synthesis. 12 | 13 | Have Fun! 14 | 15 | --- 16 | 17 | ### Installation 18 | 19 | ``` 20 | npm install 21 | ``` 22 | 23 | Mac OSX users will have to install an alternative speaker backend: 24 | 25 | ``` 26 | npm install speaker --mpg123-backend=openal --no-save 27 | ``` 28 | 29 | Start the server: 30 | 31 | ``` 32 | node start.js 33 | ``` 34 | 35 | #### Alternative deepspeech model directory 36 | 37 | The example expect deepspeech-0.7.3-models to be located at the root of the `deepspeech-plugin` directory. To specify an alternate location use the `DEEPSPEECH_MODEL` environment variable: 38 | 39 | ``` 40 | DEEPSPEECH_MODEL=/path/to/deepspeech-models node start.js 41 | ``` 42 | 43 | If you haven't installed the deepspeech models, see the instructions [here](https://github.com/jaxcore/deepspeech-plugin) -------------------------------------------------------------------------------- /examples/voice-assistant-toolbox/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "voice-assistant-toolbox", 3 | "version": "0.0.1", 4 | "description": "uses bumblebee, deepspeech, and jaxcore-say to build the basics of a voice assistant", 5 | "main": "start.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bumblebee-hotword-node": "0.0.6", 13 | "jaxcore": "0.0.2", 14 | "jaxcore-say-node": "0.0.6", 15 | "speaker": "^0.5.1", 16 | "wav": "^1.0.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/voice-assistant-toolbox/start.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const jaxcore = new Jaxcore(); 3 | 4 | // PLUGINS 5 | 6 | jaxcore.addPlugin(require('bumblebee-hotword-node')); 7 | // jaxcore.addPlugin(require('jaxcore-deepspeech-plugin')); 8 | jaxcore.addPlugin(require('../../')); 9 | jaxcore.addPlugin(require('jaxcore-say-node')); 10 | 11 | // SERVICES 12 | 13 | jaxcore.defineService('Say Node', 'sayNode', {}); 14 | 15 | // jaxcore.defineService('Bumblebee Node', 'bumblebeeNode', {}); 16 | 17 | jaxcore.defineService('Deepspeech English', 'deepspeech', { 18 | modelName: 'english', 19 | modelPath: process.env.DEEPSPEECH_MODEL || __dirname + '/../../deepspeech-0.7.3-models', // path to deepspeech model 20 | silenceThreshold: 200, 21 | vadMode: 'VERY_AGGRESSIVE', 22 | debug: true 23 | }); 24 | 25 | // ADAPTER 26 | 27 | class VoiceAssistantToolbox extends Jaxcore.Adapter { 28 | static getDefaultState() { 29 | return { 30 | speechRecognitionActive: false, 31 | sayActive: false 32 | }; 33 | } 34 | 35 | constructor(store, config, theme, devices, services) { 36 | super(store, config, theme, devices, services); 37 | 38 | const {sayNode, deepspeech, bumblebeeNode} = services; 39 | 40 | bumblebeeNode.setHotword('bumblebee'); 41 | 42 | this.addEvents(deepspeech, { 43 | recognize: function(text, stats) { 44 | console.log('Recognized:', text, stats); 45 | this.say(text); 46 | } 47 | }); 48 | 49 | 50 | 51 | this.addEvents(bumblebeeNode, { 52 | start: function() { 53 | setTimeout(() => { 54 | console.log('\nTo begin, just say: BUMBLEBEE'); 55 | // this.say('To begin, just say... bumble bee'); 56 | },10); 57 | }, 58 | hotword: function(hotword) { 59 | console.log('\nHotword Detected:', hotword); 60 | if (this.state.speechRecognitionActive) { 61 | this.stopRecognition(); 62 | } 63 | else if (!this.state.speechRecognitionActive) { 64 | this.startRecognition(); 65 | } 66 | deepspeech.streamReset(); // reset to ignore speech recognition of the hotword that was spoken 67 | }, 68 | data: function (intData, sampleRate, hotword, float32arr) { 69 | if (this.state.speechRecognitionActive && !this.state.sayActive) { 70 | deepspeech.dualStreamData(intData, float32arr, sampleRate); 71 | } 72 | else { 73 | process.stdout.write('_'); 74 | } 75 | } 76 | }); 77 | 78 | bumblebeeNode.start(); 79 | } 80 | 81 | say(text) { 82 | const {sayNode, deepspeech} = this.services; 83 | this.setState({sayActive: true}); // disable recognition while using text-to-speech 84 | return new Promise((resolve, reject) => { 85 | sayNode.say(text).then(() => { 86 | // delay a bit and reset the deepspeech buffer before re-enabling recognition 87 | setTimeout(() => { 88 | deepspeech.streamReset(); 89 | this.setState({sayActive: false}); 90 | resolve(); 91 | },200); 92 | }); 93 | }) 94 | } 95 | 96 | stopRecognition() { 97 | console.log('\nStart speech recognition by saying: BUMBLEBEE'); 98 | console.log('Speech recognition disabled'); 99 | this.setState({ 100 | speechRecognitionActive: false 101 | }); 102 | this.say("speech recognition disabled"); 103 | } 104 | 105 | startRecognition() { 106 | console.log('Stop speech recognition by saying: BUMBLEBEE'); 107 | console.log('Speech recognition enabled'); 108 | this.say("speech recognition enabled").then(() => { 109 | this.setState({ 110 | speechRecognitionActive: true 111 | }); 112 | }); 113 | } 114 | } 115 | 116 | jaxcore.addAdapter('voice-assistant-toolbox', VoiceAssistantToolbox); 117 | 118 | // CONNECT THE "voice-assistant-toolbox" ADAPTER TO THE SERVICES 119 | 120 | jaxcore.defineAdapter('Voice Assistant Toolbox', { 121 | adapterType: 'voice-assistant-toolbox', 122 | serviceProfiles: [ 123 | 'Bumblebee Node', 124 | 'Deepspeech English', 125 | 'Say Node' 126 | ] 127 | }); 128 | 129 | jaxcore.connectAdapter(null, 'Voice Assistant Toolbox'); 130 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const Jaxcore = require('jaxcore'); 2 | const DeepSpeechService = require('./lib/deepspeech-service'); 3 | const {recordingStates, vadStates} = require('./lib/constants'); 4 | 5 | const plugin = { 6 | services: { 7 | deepspeech: { 8 | service: DeepSpeechService, 9 | storeType: 'client' 10 | } 11 | } 12 | }; 13 | 14 | module.exports = plugin; 15 | 16 | module.exports.recordingStates = recordingStates; 17 | module.exports.vadStates = vadStates; 18 | 19 | module.exports.start = (serviceConfig) => { 20 | return new Promise((resolve, reject) => { 21 | const jaxcore = new Jaxcore(); 22 | jaxcore.addPlugin(plugin); 23 | jaxcore.startService('deepspeech', serviceConfig, function(err, deepspeech) { 24 | if (err) reject(err); 25 | if (deepspeech) resolve(deepspeech); 26 | }); 27 | }) 28 | }; 29 | -------------------------------------------------------------------------------- /lib/constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | recordingStates: { 3 | ON: true, 4 | OFF: false 5 | }, 6 | vadStates: { 7 | SILENCE: 0, 8 | VOICE: 1, 9 | IDLE: 2 10 | }, 11 | vadModes: { 12 | NORMAL: 0, 13 | LOW_BITRATE: 1, 14 | AGGRESSIVE: 2, 15 | VERY_AGGRESSIVE: 3 16 | } 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /lib/deepspeech-process.js: -------------------------------------------------------------------------------- 1 | const DeepSpeech = require('deepspeech'); 2 | 3 | const MODEL_NAME = process.argv[2]; 4 | const DEEPSPEECH_MODEL = process.argv[3]; 5 | const DEBUG = (process.argv[6] === 'true'); 6 | 7 | println('DEEPSPEECH_MODEL', { 8 | name: MODEL_NAME, 9 | path: DEEPSPEECH_MODEL 10 | }); 11 | 12 | function createModel(modelDir, options) { 13 | // let modelPath = modelDir + '/output_graph.pbmm'; 14 | // let lmPath = modelDir + '/lm.binary'; 15 | // let triePath = modelDir + '/trie'; 16 | // let model = new DeepSpeech.Model(modelPath, options.BEAM_WIDTH); 17 | // model.enableDecoderWithLM(lmPath, triePath, options.LM_ALPHA, options.LM_BETA); 18 | let modelPath = modelDir + '.pbmm'; 19 | let scorerPath = modelDir + '.scorer'; 20 | let model = new DeepSpeech.Model(modelPath); 21 | model.enableExternalScorer(scorerPath); 22 | return model; 23 | } 24 | 25 | let deepSpeechModel = createModel(DEEPSPEECH_MODEL, { 26 | BEAM_WIDTH: 1024, 27 | LM_ALPHA: 0.75, 28 | LM_BETA: 1.85 29 | }); 30 | 31 | let modelStream = null; 32 | let recordedAudioLength = 0; 33 | 34 | function println() { 35 | if (DEBUG) console.log.apply(null, Array.from(arguments)); 36 | } 37 | function print(s) { 38 | if (DEBUG) process.stdout.write(s); 39 | } 40 | 41 | function endAudioStream(callback) { 42 | let results = intermediateDecode(); 43 | if (results) { 44 | if (callback) { 45 | callback(results); 46 | } 47 | } 48 | else { 49 | callback(); 50 | } 51 | } 52 | 53 | function resetAudioStream() { 54 | console.log('process resetAudioStream'); 55 | intermediateDecode(); // ignore results 56 | } 57 | 58 | function createStream() { 59 | if (modelStream) { 60 | console.error('modelStream exists'); 61 | process.exit(); 62 | return; 63 | } 64 | modelStream = deepSpeechModel.createStream(); 65 | recordedAudioLength = 0; 66 | } 67 | 68 | function finishStream() { 69 | if (modelStream) { 70 | let start = new Date(); 71 | let text = modelStream.finishStream(); 72 | if (text) { 73 | text = text.trim(); 74 | // if (text === 'i' || text === 'a' || text === 't') { 75 | // // bug in DeepSpeech 0.6 causes silence to be inferred as "i" or "a", and any end of a stream is inferred as "t" 76 | // return; 77 | // } 78 | if (DEBUG) { 79 | println(''); 80 | println('Recognized Text:', '"'+text+'"'); 81 | } 82 | let recogTime = new Date().getTime() - start.getTime(); 83 | return { 84 | text, 85 | recogTime, 86 | audioLength: Math.round(recordedAudioLength) 87 | }; 88 | } 89 | } 90 | modelStream = null; 91 | } 92 | 93 | function intermediateDecode() { 94 | let results = finishStream(); 95 | if (modelStream) { 96 | modelStream = null; 97 | } 98 | createStream(); 99 | return results; 100 | } 101 | 102 | function feedAudioContent(chunk) { 103 | recordedAudioLength += (chunk.length / 2) * (1 / 16000) * 1000; 104 | modelStream.feedAudioContent(chunk); 105 | } 106 | createStream(); 107 | 108 | function sendResults(results) { 109 | if (results) { 110 | process.send({ 111 | recognize: { 112 | text: results.text, 113 | stats: { 114 | recogTime: results.recogTime, 115 | audioLength: results.audioLength, 116 | model: MODEL_NAME 117 | } 118 | } 119 | }); 120 | } 121 | else { 122 | process.send({ 123 | noRecognition: true 124 | }); 125 | } 126 | } 127 | 128 | process.on('message', function (data) { 129 | if (typeof data === 'string') { 130 | let msg = data; 131 | 132 | if (msg === 'stream-reset') { 133 | resetAudioStream(); 134 | } 135 | else if (msg === 'stream-end') { 136 | endAudioStream((results) => { 137 | sendResults(results); 138 | }); 139 | } 140 | } 141 | else if (data.data && data.data.length > 1) { 142 | let audio = Buffer.from(data); 143 | feedAudioContent(audio); 144 | } 145 | }); 146 | 147 | println('deepspeech-process ready...'); 148 | process.send({ 149 | ready: true 150 | }); 151 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jaxcore-deepspeech-plugin", 3 | "version": "0.0.7", 4 | "description": "Mozilla DeepSpeech speech recognition plugin for Jaxcore", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "copy-examples": "rm -rf docs/examples/* && mv examples/web-demo/build/ docs/examples/web-demo && mv examples/web-vocab-tester/build/ docs/examples/web-vocab-tester" 9 | }, 10 | "author": "Jaxcore", 11 | "license": "MIT", 12 | "dependencies": { 13 | "csvtojson": "^2.0.8", 14 | "deepspeech": "^0.7.3", 15 | "jaxcore": "0.0.2", 16 | "node-abi": "^2.18.0", 17 | "node-vad": "^1.1.4", 18 | "pcm-convert": "^1.6.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tools/ascii.csv: -------------------------------------------------------------------------------- 1 | 0,"NUL","null","no character","nil",,,, 2 | 1,"SOH","start of header","start of head or","start of heather","start of hatter",,, 3 | 2,"STX","start of text","start a tax","start of tax",,,, 4 | 3,"ETX","end of text","and of text","and of tax",,,, 5 | 4,"EOT","end of transmission","and of transmission",,,,, 6 | 5,"ENQ","enquiry","and quarry","and carry","inquiry",,, 7 | 6,"ACK","acknowledgment",,,,,, 8 | 7,"BEL","bell",,,,,, 9 | 8,"BS","back space",,,,,, 10 | 9,"HT","tab","horizontal tab",,,,, 11 | 10,"LF","line feed","line feet",,,,, 12 | 11,"VT","vertical tab",,,,,, 13 | 12,"FF","form feed",,,,,, 14 | 13,"CR","enter","return","carriage return",,,, 15 | 14,"SO","shift out",,,,,, 16 | 15,"SI","shift in",,,,,, 17 | 16,"DLE","data link escape",,,,,, 18 | 17,"DC1","device control one",,,,,, 19 | 18,"DC2","device control two","device control to",,,,, 20 | 19,"DC3","device control three",,,,,, 21 | 20,"DC4","device control four","device control for",,,,, 22 | 21,"NAK","negative acknowledgment",,,,,, 23 | 22,"SYN","synchronize",,,,,, 24 | 23,"ETB","end of transmission block","and of transmission block",,,,, 25 | 24,"CAN","cancel",,,,,, 26 | 25,"EM","end of medium","and of medium",,,,, 27 | 26,"SUB","substitute",,,,,, 28 | 27,"ESC","escape",,,,,, 29 | 28,"FS","file separator",,,,,, 30 | 29,"GS","group separator",,,,,, 31 | 30,"RS","record separator",,,,,, 32 | 31,"US","unit separator",,,,,, 33 | 32," ","space",,,,,, 34 | 33,"!","exclamation","exclamation mark","exclamation point",,,, 35 | 34,"""","double quote","quote","quite","quoth",,, 36 | 35,"#","number","hash","hush",,,, 37 | 36,"$","dollar","dollars",,,,, 38 | 37,"%","percent","per cent",,,,, 39 | 38,"&","ampersand",,,,,, 40 | 39,"'","single quote",,,,,, 41 | 40,"(","left parenthesis","left brace","left perinthus",,,, 42 | 41,")","right parenthesis","right brace","right perinthus",,,, 43 | 42,"*","asterisk","as rick","as struck","times","a trick",, 44 | 43,"+","plus","positive",,,,, 45 | 44,",","comma","come","camma",,,, 46 | 45,"-","minus","negative",,,,, 47 | 46,".","period","dot","point","full stop",,, 48 | 47,"/","slash",,,,,, 49 | 48,0,"zero",,,,,, 50 | 49,1,"one","on",,,,, 51 | 50,2,"two","to",,,,, 52 | 51,3,"three","tree","free","through",,, 53 | 52,4,"four","for",,,,, 54 | 53,5,"five",,,,,, 55 | 54,6,"six","sex",,,,, 56 | 55,7,"seven",,,,,, 57 | 56,8,"eight","each","it",,,, 58 | 57,9,"nine",,,,,, 59 | 58,":","colon","call on","cool and","call in","coal and","colin", 60 | 59,";","semi colon","some call",,,,, 61 | 60,"<","less than",,,,,, 62 | 61,"=","equals","equal","equality","equality sign","equal sign",, 63 | 62,">","greater than",,,,,, 64 | 63,"?","question","question mark",,,,, 65 | 64,"@","at","at sign",,,,, 66 | 65,"A",,,,,,, 67 | 66,"B",,,,,,, 68 | 67,"C",,,,,,, 69 | 68,"D",,,,,,, 70 | 69,"E",,,,,,, 71 | 70,"F",,,,,,, 72 | 71,"G",,,,,,, 73 | 72,"H",,,,,,, 74 | 73,"I",,,,,,, 75 | 74,"J",,,,,,, 76 | 75,"K",,,,,,, 77 | 76,"L",,,,,,, 78 | 77,"M",,,,,,, 79 | 78,"N",,,,,,, 80 | 79,"O",,,,,,, 81 | 80,"P",,,,,,, 82 | 81,"Q",,,,,,, 83 | 82,"R",,,,,,, 84 | 83,"S",,,,,,, 85 | 84,"T",,,,,,, 86 | 85,"U",,,,,,, 87 | 86,"V",,,,,,, 88 | 87,"W",,,,,,, 89 | 88,"X",,,,,,, 90 | 89,"Y",,,,,,, 91 | 90,"Z",,,,,,, 92 | 91,"[","left square bracket","left square brace",,,,, 93 | 92,"\","backslash","back slash","back lash",,,, 94 | 93,"]","right square bracket","right square brace",,,,, 95 | 94,"^","caret","circumflex","carrot",,,, 96 | 95,"_","underscore","under score",,,,, 97 | 96,"`","grave","accent",,,,, 98 | 97,"a","alpha","alvar","alva",,,, 99 | 98,"b","be","bravo",,,,, 100 | 99,"c","sea","see","charlie","charles","charley","charl", 101 | 100,"d","de","delta","dolt","dealt",,, 102 | 101,"e","he",,,,,, 103 | 102,"f","if","ah","fox trot","fox to",,, 104 | 103,"g","golf","go",,,,, 105 | 104,"h","eh","age","each","hotel","potel","bach","ach" 106 | 105,"i",,,,,,, 107 | 106,"j","ja",,,,,, 108 | 107,"k","kay",,,,,, 109 | 108,"l","ll",,,,,, 110 | 109,"m","am",,,,,, 111 | 110,"n","en","in","and","an",,, 112 | 111,"o","oh",,,,,, 113 | 112,"p","pea",,,,,, 114 | 113,"q","cue","let her cue","cute","que",,, 115 | 114,"r","are",,,,,, 116 | 115,"s","as",,,,,, 117 | 116,"t","tea",,,,,, 118 | 117,"u","you",,,,,, 119 | 118,"v","ve",,,,,, 120 | 119,"w","double you",,,,,, 121 | 120,"x","ex",,,,,, 122 | 121,"y","why",,,,,, 123 | 122,"z","ze","zed","said",,,, 124 | 123,"{","left curly bracket","left curly brace",,,,, 125 | 124,"|","bar","pipe","vertical bar",,,, 126 | 125,"}","right curly bracket","right curly brace",,,,, 127 | 126,"~","tilde","till the","till a",,,, 128 | 127,"DEL","delete",,,,,, 129 | 162,"¢","cent","cents","since","sent",,, 130 | 163,"£","pound","pounds",,,,, 131 | 165,"¥","yen","yuan",,,,, 132 | 169,"©","copyright","copy right",,,,, 133 | 174,"®","trademark","registered trademark","trade mark","registered trade mark",,, 134 | 176,"°","degree","degrees",,,,, 135 | 215,"×","multiply","multiplied","multiplication","multiplication sign","multiply by","multiplied by", 136 | 247,"÷","divide","divide by","divided","divided by","obelus",, 137 | -------------------------------------------------------------------------------- /tools/chess.csv: -------------------------------------------------------------------------------- 1 | 1,"one",,,,,,,,, 2 | 2,"two","to",,,,,,,, 3 | 3,"three","tree","free","through",,,,,, 4 | 4,"four","for",,,,,,,, 5 | 5,"five","i've",,,,,,,, 6 | 6,"six","sex",,,,,,,, 7 | 7,"seven",,,,,,,,, 8 | 8,"eight",,,,,,,,, 9 | "a","a","letter a","alpha","all the",,,,,, 10 | "b","b","letter b","be","bravo",,,,,, 11 | "c","c","letter c","sea","see","charlie","charles","charley","charl",, 12 | "d","d","letter d","de","delta","dolt","dealt",,,, 13 | "e","e","letter e","he","letter he",,,,,, 14 | "f","f","letter f","if","ah","as","at","fox trot","fox to","of", 15 | "g","g","letter g","j","letter j","ja","ji","golf","go",, 16 | "h","h","letter h","eh","age","each","hotel","potel","bach","ach","each" 17 | "P","pawn","pon","paw","pan","on","upon","tom",,, 18 | "N","knight","night","net","neat","might","knit",,,, 19 | "K","king",,,,,,,,, 20 | "Q","queen","cream",,,,,,,, 21 | "R","rook","ruck","rock","wreck","rap",,,,, 22 | "B","bishop","ship",,,,,,,, 23 | "castle king side","castle king side","castle king","castle kings","castle king so","cattle kings","at king's side","castle king's side","castle king's eyed",, 24 | "castle queen side","castle queen side","castle queen","castle queens","castle queen so","cattle queens","castle quin","at queen's side","a quinsie","castle queen's eyed", 25 | "castle","castle",,,,,,,,, 26 | "en passant","en passant","in person","un passant","and person","in person","and passant",,,, 27 | "promote","promote",,,,,,,,, 28 | "takeback","take back",,,,,,,,, 29 | "rotate","rotate","rotate board","tate","rode hate","he wrote to","rotha","rose had",,, 30 | "reverse board","reverse board","flip board",,,,,,,, 31 | "select","select",,,,,,,,, 32 | "cancel","cancel",,,,,,,,, 33 | "menu","menu","many","men you",,,,,,, 34 | "resign","resign","i resign","resigned","i resigned",,,,,, 35 | "draw","draw","offer draw",,,,,,,, 36 | "yes","yes","okay","alright","all right",,,,,, 37 | "no","no",,,,,,,,, 38 | "accept","accept","except",,,,,,,, 39 | "decline","decline",,,,,,,,, 40 | "forward","forward",,,,,,,,, 41 | "reverse","reverse",,,,,,,,, 42 | "port","port",,,,,,,,, 43 | "starboard","starboard","star board","star word","starward","star bore",,,,, 44 | "left","left","let","laughed","laugh",,,,,, 45 | "right","right",,,,,,,,, 46 | "up","up",,,,,,,,, 47 | "down","down",,,,,,,,, 48 | "next","next","not","net",,,,,,, 49 | "previous","previous",,,,,,,,, 50 | "takes","takes","take",,,,,,,, 51 | "captures","captures","capture",,,,,,,, 52 | "help","help","show help",,,,,,,, 53 | "new game","new game",,,,,,,,, 54 | "save game","save game",,,,,,,,, 55 | "load game","load game",,,,,,,,, 56 | "pause","pause",,,,,,,,, 57 | -------------------------------------------------------------------------------- /tools/chess.json: -------------------------------------------------------------------------------- 1 | {"1":["one"],"2":["two","to"],"3":["three","tree","free","through"],"4":["four","for"],"5":["five","i've"],"6":["six","sex"],"7":["seven"],"8":["eight"],"a":["a","letter a","alpha","all the"],"b":["b","letter b","be","bravo"],"c":["c","letter c","sea","see","charlie","charles","charley","charl"],"d":["d","letter d","de","delta","dolt","dealt"],"e":["e","letter e","he","letter he"],"f":["f","letter f","if","ah","as","at","fox trot","fox to","of"],"g":["g","letter g","j","letter j","ja","ji","golf","go"],"h":["h","letter h","eh","age","each","hotel","potel","bach","ach","each"],"P":["pawn","pon","paw","pan","on","upon","tom"],"N":["knight","night","net","neat","might","knit"],"K":["king"],"Q":["queen","cream"],"R":["rook","ruck","rock","wreck"],"B":["bishop","ship"],"castle king side":["castle king side","castle king","castle kings","castle king so","cattle kings","at king's side"],"castle queen side":["castle queen side","castle queen","castle queens","castle queen so","cattle queens","castle quin","at queen's side","a quinsie"],"castle":["castle"],"en passant":["en passant","in person","un passant","and person","in person","and passant"],"promote":["promote"],"takeback":["take back"],"rotate":["rotate","rotate board","tate","rode hate","he wrote to","rotha","rose had"],"reverse board":["reverse board","flip board"],"select":["select"],"cancel":["cancel"],"menu":["menu","many","men you"],"resign":["resign","i resign","resigned","i resigned"],"draw":["draw","offer draw"],"yes":["yes","okay","alright","all right"],"no":["no"],"accept":["accept","except"],"decline":["decline"],"forward":["forward"],"reverse":["reverse"],"port":["port"],"starboard":["starboard","star board","star word","starward","star bore"],"left":["left","let","laughed","laugh"],"right":["right"],"up":["up"],"down":["down"],"next":["next","not","net"],"previous":["previous"],"takes":["takes","take"],"captures":["captures","capture"],"help":["help","show help"],"new game":["new game"],"save game":["save game"],"load game":["load game"],"pause":["pause"],"the":["the"]} -------------------------------------------------------------------------------- /tools/datetime.csv: -------------------------------------------------------------------------------- 1 | april,a roll,he pro, 2 | october,taber,tiber, 3 | tuesday,to stay,, 4 | wednesday,when stay,, 5 | tomorrow,to morrow,, 6 | today,to day,, 7 | AM,a m,, 8 | PM,p m,, 9 | two,to,, 10 | three,tree,free,through 11 | four,for,, 12 | five,i've,, 13 | six,sex,, 14 | -------------------------------------------------------------------------------- /tools/datetime.json: -------------------------------------------------------------------------------- 1 | {"april":["a roll","he pro"],"october":["taber","tiber"],"tuesday":["to stay"],"wednesday":["when stay"],"tomorrow":["to morrow"],"today":["to day"],"AM":["a m"],"PM":["p m"],"two":["to"],"three":["tree","free","through"],"four":["for"],"five":["i've"],"six":["sex"]} -------------------------------------------------------------------------------- /tools/generate-ascii.js: -------------------------------------------------------------------------------- 1 | const csv = require('csvtojson'); 2 | 3 | const csvFilePath = __dirname + '/ascii.csv'; 4 | 5 | csv({ 6 | noheader: true, 7 | output: 'csv' 8 | // headers: ['dec', 'char', '1', '2', '3', '4', '5', '6','7'], 9 | }).fromFile(csvFilePath).then((ascii) => { 10 | // console.log('ascii loaded', ascii); 11 | 12 | const asciiChars = {}; 13 | 14 | ascii.forEach((row) => { 15 | let d = row[0]; 16 | let c = row[1]; 17 | 18 | if (d === '32') { 19 | c = " "; 20 | } 21 | 22 | let words = []; 23 | for (let w = 2; w < 10; w++) { 24 | if (row[w]!=='' && row[w]!==undefined && row[w]!==null) { 25 | words.push(row[w]); 26 | } 27 | } 28 | 29 | console.log(words); 30 | 31 | if (words.length) { 32 | asciiChars[d] = [c,words]; 33 | } 34 | else asciiChars[d] = [c]; 35 | }); 36 | 37 | require('fs').writeFileSync(__dirname + '/ascii.json', JSON.stringify(asciiChars)); 38 | console.log('wrote ascii.json'); 39 | process.exit(); 40 | 41 | }).catch((e) => { 42 | console.error(e); 43 | process.exit(); 44 | }); 45 | 46 | // https://en.wikipedia.org/wiki/C0_and_C1_control_codes -------------------------------------------------------------------------------- /tools/generate-chess.js: -------------------------------------------------------------------------------- 1 | const csv = require('csvtojson'); 2 | 3 | const csvFilePath = __dirname + '/chess.csv'; 4 | 5 | csv({ 6 | noheader: true, 7 | output: 'csv' 8 | }).fromFile(csvFilePath).then((result) => { 9 | let keys = {}; 10 | result.forEach(row => { 11 | let key = row.shift(); 12 | let newrow = []; 13 | for (let r=0;r { 26 | console.error(e); 27 | process.exit(); 28 | }); -------------------------------------------------------------------------------- /tools/generate-substitutions.js: -------------------------------------------------------------------------------- 1 | // type: 2 | // node generate-substitutions.js datetime.csv 3 | 4 | const csv = require('csvtojson'); 5 | 6 | const csvFilePath = process.argv[2]; 7 | 8 | csv({ 9 | noheader: true, 10 | output: 'csv' 11 | }).fromFile(csvFilePath).then((result) => { 12 | // console.log('loaded', result); 13 | 14 | let keys = {}; 15 | result.forEach(row => { 16 | let key = row[0]; 17 | let newrow = []; 18 | for (let r=1;r { 32 | console.error(e); 33 | process.exit(); 34 | }); --------------------------------------------------------------------------------