Skip to content

Commit 28efa49

Browse files
laljikanjareeyaAce Nassri
authored andcommitted
docs(samples): update node-record-lpcm16 and related changes (#403)
1 parent 8eb80be commit 28efa49

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

speech/infiniteStreaming.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function infiniteStream(
6363
const {Transform} = require('stream');
6464

6565
// Node-Record-lpcm16
66-
const record = require('node-record-lpcm16');
66+
const recorder = require('node-record-lpcm16');
6767

6868
// Imports the Google Cloud client library
6969
// Currently, only v1p1beta1 contains result-end-time
@@ -210,14 +210,15 @@ function infiniteStream(
210210
startStream();
211211
}
212212
// Start recording and send the microphone input to the Speech API
213-
record
214-
.start({
213+
recorder
214+
.record({
215215
sampleRateHertz: sampleRateHertz,
216216
threshold: 0, // Silence threshold
217217
silence: 1000,
218218
keepSilence: true,
219219
recordProgram: 'rec', // Try also "arecord" or "sox"
220220
})
221+
.stream()
221222
.on('error', err => {
222223
console.error('Audio recording error ' + err);
223224
})

speech/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@google-cloud/speech": "^3.2.3",
1515
"@google-cloud/storage": "^2.0.0",
1616
"chalk": "^2.4.2",
17-
"node-record-lpcm16": "^0.3.0",
17+
"node-record-lpcm16": "^1.0.1",
1818
"sox": "^0.1.0",
1919
"yargs": "^13.0.0"
2020
},

speech/recognize.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ async function streamingRecognize(
380380

381381
function streamingMicRecognize(encoding, sampleRateHertz, languageCode) {
382382
// [START speech_transcribe_streaming_mic]
383-
const record = require('node-record-lpcm16');
383+
const recorder = require('node-record-lpcm16');
384384

385385
// Imports the Google Cloud client library
386386
const speech = require('@google-cloud/speech');
@@ -417,15 +417,16 @@ function streamingMicRecognize(encoding, sampleRateHertz, languageCode) {
417417
);
418418

419419
// Start recording and send the microphone input to the Speech API
420-
record
421-
.start({
420+
recorder
421+
.record({
422422
sampleRateHertz: sampleRateHertz,
423423
threshold: 0,
424424
// Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
425425
verbose: false,
426426
recordProgram: 'rec', // Try also "arecord" or "sox"
427427
silence: '10.0',
428428
})
429+
.stream()
429430
.on('error', console.error)
430431
.pipe(recognizeStream);
431432

0 commit comments

Comments
 (0)