Skip to content

Commit

Permalink
Update node example with downloadable audio files
Browse files Browse the repository at this point in the history
  • Loading branch information
dsteinman committed Mar 3, 2019
1 parent 9554d2c commit 6e7123f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
21 changes: 18 additions & 3 deletions examples/nodejs_wav/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ Install Sox (for .wav file loading):
brew install sox
```

Download test audio files:

```
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.4.1/audio-0.4.1.tar.gz
tar xfvz audio-0.4.1.tar.gz
```

Install NPM dependencies:

```
Expand All @@ -37,8 +44,16 @@ node index.js
Result should be something like:

```
2019-02-22 13:13:44.271363: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
audio length 2.0241875
result: more lurtee speech
audio length 1.975
result: experience proves this
```

Try other wav files with an argument:

```
node index.js audio/2830-3980-0043.wav
node index.js audio/8455-210777-0068.wav
node index.js audio/4507-16021-0012.wav
```

Binary file removed examples/nodejs_wav/audio.wav
Binary file not shown.
8 changes: 5 additions & 3 deletions examples/nodejs_wav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ let triePath = './models/trie';

model.enableDecoderWithLM(alphabetPath, lmPath, triePath, LM_ALPHA, LM_BETA);

if (!Fs.existsSync('./audio.wav')) {
console.log('audio.wav file in current path');
let audioFile = process.argv[2] || './audio/2830-3980-0043.wav';

if (!Fs.existsSync(audioFile)) {
console.log('file missing:', audioFile);
process.exit();
}

const buffer = Fs.readFileSync('./audio.wav');
const buffer = Fs.readFileSync(audioFile);
const result = Wav.decode(buffer);

if (result.sampleRate < 16000) {
Expand Down

0 comments on commit 6e7123f

Please sign in to comment.