Skip to content

Commit 06f8a0a

Browse files
committed
cleanup
1 parent ef76024 commit 06f8a0a

4 files changed

Lines changed: 44 additions & 40 deletions

File tree

examples/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"no-console": "off",
44
"node/no-missing-require": "off",
55
"require-jsdoc": "off",
6-
"valid-jsdoc": "off"
6+
"valid-jsdoc": "off",
7+
"no-process-exit": "off"
78
}
89
};

examples/speech_to_text_microphone_input/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"dependencies": {
1414
"dotenv": "^4.0.0",
1515
"line-in": "^0.1.2",
16+
"mic": "^2.1.1",
1617
"watson-developer-cloud": "^2.33.0",
1718
"wav": "^1.0.1"
1819
}

examples/speech_to_text_microphone_input/transcribe-mic-to-console.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1+
'use strict';
12
require('dotenv').config({ silent: true }); // optional, handy for local development
2-
var SpeechToText = require('watson-developer-cloud/speech-to-text/v1');
3-
var LineIn = require('line-in'); // the `mic` package also works - it's more flexible but requires a bit more setup
4-
var wav = require('wav');
5-
6-
7-
var speechToText = new SpeechToText({
8-
// if left unspecified here, the SDK will fall back to the SPEECH_TO_TEXT_USERNAME and SPEECH_TO_TEXT_PASSWORD
9-
// environment properties, and then Bluemix's VCAP_SERVICES environment property
10-
// username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
11-
// password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE'
12-
});
13-
14-
var lineIn = new LineIn(); // 2-channel 16-bit little-endian signed integer pcm encoded audio @ 44100 Hz
15-
16-
var wavStream = new wav.Writer({
3+
const SpeechToText = require('watson-developer-cloud/speech-to-text/v1');
4+
const LineIn = require('line-in'); // the `mic` package also works - it's more flexible but requires a bit more setup
5+
const wav = require('wav');
6+
7+
const speechToText = new SpeechToText(
8+
{
9+
// if left unspecified here, the SDK will fall back to the SPEECH_TO_TEXT_USERNAME and SPEECH_TO_TEXT_PASSWORD
10+
// environment properties, and then Bluemix's VCAP_SERVICES environment property
11+
// username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
12+
// password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE'
13+
}
14+
);
15+
16+
const lineIn = new LineIn(); // 2-channel 16-bit little-endian signed integer pcm encoded audio @ 44100 Hz
17+
18+
const wavStream = new wav.Writer({
1719
sampleRate: 44100,
1820
channels: 2
1921
});
2022

21-
var recognizeStream = speechToText.createRecognizeStream({'content_type': 'audio/wav'});
23+
const recognizeStream = speechToText.createRecognizeStream({ content_type: 'audio/wav' });
2224

2325
lineIn.pipe(wavStream);
2426

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
var fs = require('fs');
1+
'use strict';
2+
const fs = require('fs');
23
require('dotenv').config({ silent: true }); // optional, handy for local development
3-
var SpeechToText = require('watson-developer-cloud/speech-to-text/v1');
4-
var mic = require('mic');
5-
var wav = require('wav');
6-
7-
8-
var speechToText = new SpeechToText({
9-
// if left unspecified here, the SDK will fall back to the SPEECH_TO_TEXT_USERNAME and SPEECH_TO_TEXT_PASSWORD
10-
// environment properties, and then Bluemix's VCAP_SERVICES environment property
11-
// username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
12-
// password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE'
13-
});
14-
15-
var micInstance = mic({
16-
'rate': '48000',
17-
'channels': '1',
18-
'debug': false
4+
const SpeechToText = require('watson-developer-cloud/speech-to-text/v1');
5+
const mic = require('mic');
6+
const wav = require('wav');
7+
8+
const speechToText = new SpeechToText(
9+
{
10+
// if left unspecified here, the SDK will fall back to the SPEECH_TO_TEXT_USERNAME and SPEECH_TO_TEXT_PASSWORD
11+
// environment properties, and then Bluemix's VCAP_SERVICES environment property
12+
// username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
13+
// password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE'
14+
}
15+
);
16+
17+
const micInstance = mic({
18+
rate: '48000',
19+
channels: '1',
20+
debug: false
1921
});
2022

21-
var micInputStream = micInstance.getAudioStream();
22-
23+
const micInputStream = micInstance.getAudioStream();
2324

24-
var wavStream = new wav.FileWriter('./audio.wav', {
25+
const wavStream = new wav.FileWriter('./audio.wav', {
2526
sampleRate: 48000,
2627
channels: 1
2728
});
2829

29-
var recognizeStream = speechToText.createRecognizeStream({'content_type': 'audio/wav'});
30+
const recognizeStream = speechToText.createRecognizeStream({ content_type: 'audio/wav' });
3031

3132
micInputStream.pipe(wavStream);
3233

@@ -48,8 +49,7 @@ process.stdin.once('data', function() {
4849
micInstance.stop();
4950
recognizeStream.on('end', function() {
5051
process.exit();
51-
})
52+
});
5253
});
5354

54-
5555
micInstance.start();

0 commit comments

Comments
 (0)