Skip to content

Commit d0b70a4

Browse files
committed
chore: Merge branch 'master' into regenerate-sdk-release-5
2 parents 40b137d + 314908a commit d0b70a4

File tree

10 files changed

+521
-20
lines changed

10 files changed

+521
-20
lines changed

.releaserc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"branch": "master",
3+
"verifyConditions": ["@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git"],
4+
"prepare": ["@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git"],
35
"publish": [
46
"@semantic-release/npm",
57
{

CHANGELOG.md

Lines changed: 484 additions & 1 deletion
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ speechToText.recognize(params, function(err, res) {
560560

561561
// or streaming
562562
fs.createReadStream('./resources/speech.wav')
563-
.pipe(speechToText.createRecognizeStream({ content_type: 'audio/l16; rate=44100' }))
563+
.pipe(speechToText.recognizeUsingWebSocket({ content_type: 'audio/l16; rate=44100' }))
564564
.pipe(fs.createWriteStream('./transcription.txt'));
565565
```
566566

examples/speech_to_text.v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var params = {
2222
};
2323

2424
// create the stream
25-
var recognizeStream = speechToText.createRecognizeStream(params);
25+
var recognizeStream = speechToText.recognizeUsingWebSocket(params);
2626

2727
// pipe in some audio
2828
fs.createReadStream(__dirname + '/resources/speech.wav').pipe(recognizeStream);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var wavStream = new wav.Writer({
1818
channels: 2,
1919
});
2020

21-
var recognizeStream = speechToText.createRecognizeStream({
21+
var recognizeStream = speechToText.recognizeUsingWebSocket({
2222
content_type: 'audio/wav',
2323
});
2424

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var wavStream = new wav.FileWriter('./audio.wav', {
2525
channels: 1,
2626
});
2727

28-
var recognizeStream = speechToText.createRecognizeStream({
28+
var recognizeStream = speechToText.recognizeUsingWebSocket({
2929
content_type: 'audio/wav',
3030
});
3131

lib/recognize-stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ interface RecognizeStream extends Duplex {
5656
* pipe()-able Node.js Readable/Writeable stream - accepts binary audio and emits text in it's `data` events.
5757
* Also emits `results` events with interim results and other data.
5858
*
59-
* Cannot be instantiated directly, instead reated by calling #createRecognizeStream()
59+
* Cannot be instantiated directly, instead created by calling #recognizeUsingWebSocket()
6060
*
6161
* Uses WebSockets under the hood. For audio with no recognizable speech, no `data` events are emitted.
6262
* @param {Object} options

speech-to-text/v1.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class SpeechToTextV1 extends GeneratedSpeechToTextV1 {
301301
* Sets 'Transfer-Encoding': 'chunked' and prepare the connection to send
302302
* chunk data.
303303
*
304-
* @deprecated use createRecognizeStream instead
304+
* @deprecated use recognizeUsingWebSocket instead
305305
*
306306
* @param {Object} params The parameters
307307
* @param {String} [params.content_type] - The Content-type e.g. audio/l16; rate=48000
@@ -373,7 +373,7 @@ class SpeechToTextV1 extends GeneratedSpeechToTextV1 {
373373
* This request has to be started before POST on recognize finishes,
374374
* otherwise it waits for the next recognition.
375375
*
376-
* @deprecated use createRecognizeStream instead
376+
* @deprecated use recognizeUsingWebSocket instead
377377
*
378378
* @param {Object} params The parameters
379379
* @param {String} [params.session_id] - Session used in the recognition
@@ -440,8 +440,20 @@ class SpeechToTextV1 extends GeneratedSpeechToTextV1 {
440440
*
441441
* @param {Object} params The parameters
442442
* @return {RecognizeStream}
443+
* @deprecated
443444
*/
444445
createRecognizeStream(params) {
446+
console.warn("WARNING: createRecognizeStream() was renamed to recognizeUsingWebSocket(). Support for createRecognizeStream() will be removed in the next major release");
447+
return this.recognizeUsingWebSocket(params);
448+
}
449+
450+
/**
451+
* Use the recognize function with a single 2-way stream over websockets
452+
*
453+
* @param {Object} params The parameters
454+
* @return {RecognizeStream}
455+
*/
456+
recognizeUsingWebSocket(params) {
445457
params = params || {};
446458
params.url = this._options.url;
447459

test/integration/test.speech_to_text.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('speech_to_text_integration', function() {
124124
speech_to_text.getModels({}, done);
125125
});
126126

127-
describe('createRecognizeStream() (RC) (credentials from environment/VCAP) @slow', () => {
127+
describe('recognizeUsingWebSocket() (RC) (credentials from environment/VCAP) @slow', () => {
128128
let env;
129129
beforeEach(function() {
130130
env = process.env;
@@ -138,7 +138,7 @@ describe('speech_to_text_integration', function() {
138138
process.env.SPEECH_TO_TEXT_IAM_APIKEY = auth.speech_to_text_rc.iam_apikey;
139139
process.env.SPEECH_TO_TEXT_URL = auth.speech_to_text_rc.url;
140140
const speech_to_text_env = new watson.SpeechToTextV1({});
141-
const recognizeStream = speech_to_text_env.createRecognizeStream();
141+
const recognizeStream = speech_to_text_env.recognizeUsingWebSocket();
142142
recognizeStream.setEncoding('utf8');
143143
fs
144144
.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -168,7 +168,7 @@ describe('speech_to_text_integration', function() {
168168
],
169169
});
170170
const speech_to_text_vcap = new watson.SpeechToTextV1({});
171-
const recognizeStream = speech_to_text_vcap.createRecognizeStream();
171+
const recognizeStream = speech_to_text_vcap.recognizeUsingWebSocket();
172172
recognizeStream.setEncoding('utf8');
173173
fs
174174
.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -187,9 +187,9 @@ describe('speech_to_text_integration', function() {
187187
});
188188
});
189189

190-
describe('createRecognizeStream() (RC)', () => {
190+
describe('recognizeUsingWebSocket() (RC)', () => {
191191
it('transcribes audio over a websocket @slow', function(done) {
192-
const recognizeStream = speech_to_text_rc.createRecognizeStream();
192+
const recognizeStream = speech_to_text_rc.recognizeUsingWebSocket();
193193
recognizeStream.setEncoding('utf8');
194194
fs
195195
.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -208,9 +208,9 @@ describe('speech_to_text_integration', function() {
208208
});
209209
});
210210

211-
describe('createRecognizeStream()', () => {
211+
describe('recognizeUsingWebSocket()', () => {
212212
it('transcribes audio over a websocket @slow', function(done) {
213-
const recognizeStream = speech_to_text.createRecognizeStream();
213+
const recognizeStream = speech_to_text.recognizeUsingWebSocket();
214214
recognizeStream.setEncoding('utf8');
215215
fs
216216
.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -229,7 +229,7 @@ describe('speech_to_text_integration', function() {
229229
});
230230

231231
it('works when stream has no words', function(done) {
232-
const recognizeStream = speech_to_text.createRecognizeStream({
232+
const recognizeStream = speech_to_text.recognizeUsingWebSocket({
233233
content_type: 'audio/l16; rate=44100',
234234
});
235235
recognizeStream.setEncoding('utf8');

test/unit/test.speech_to_text.v1.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,26 +245,30 @@ describe('speech_to_text', function() {
245245
});
246246
});
247247

248-
describe('createRecognizeStream()', function() {
248+
describe('recognizeUsingWebSocket()', function() {
249249
it('should return a stream', function() {
250-
assert(isStream(speech_to_text.createRecognizeStream()));
250+
assert(isStream(speech_to_text.recognizeUsingWebSocket()));
251251
});
252252

253253
it('should pass the correct parameters into RecognizeStream', function() {
254-
const stream = speech_to_text.createRecognizeStream();
254+
const stream = speech_to_text.recognizeUsingWebSocket();
255255
assert.equal(stream.options.url, service.url);
256256
assert(stream.options.headers.authorization);
257257
assert(stream.authenticated);
258258
assert.equal(stream.options.token_manager, undefined);
259259
});
260260

261261
it('should create a token manager in RecognizeStream if using IAM', function() {
262-
const stream = rc_speech_to_text.createRecognizeStream();
262+
const stream = rc_speech_to_text.recognizeUsingWebSocket();
263263
assert.equal(stream.options.url, service.url);
264264
assert.equal(stream.options.headers.authorization, undefined);
265265
assert.equal(stream.authenticated, false);
266266
assert(stream.options.token_manager);
267267
});
268+
269+
it('createRecognizeStream should return a stream - compatibility', function() {
270+
assert(isStream(speech_to_text.createRecognizeStream()));
271+
});
268272
});
269273

270274
describe('asynchronous callback api', function() {

0 commit comments

Comments
 (0)