Skip to content

Commit 0307f84

Browse files
author
Jeff Lu
committed
remove continuous from OPENING_MESSAGE_PARAMS_ALLOWED
1 parent 39e2da4 commit 0307f84

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ examples/node_modules/
1313
dist/*.js
1414
examples/static/bower_components/
1515
gh-pages/
16+
.idea

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ There have been a few breaking changes in recent releases:
128128
* Changed format of objects emitted in objectMode to exactly match what service sends. Added `ResultStream` class and `extract_results` option to enable older behavior.
129129
* Changed `playback-error` event to just `error` when recognizing and playing a file. Check for `error.name == 'UNSUPPORTED_FORMAT'` to identify playback errors. This error is special in that it does not stop the streaming of results.
130130
* Renamed `recognizeFile()`'s `data` option to `file` because it now may be a URL. Using a URL enables faster playback and mobile Safari support
131+
* Continous flag for OPENING_MESSAGE_PARAMS_ALLOWED has been removed
131132

132133
See [CHANGELOG.md](CHANGELOG.md) for a complete list of changes.
133134

examples/static/microphone-streaming-auto-stop.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ <h2>Code for this demo:</h2>
3434

3535
var stream = WatsonSpeech.SpeechToText.recognizeMicrophone({
3636
token: token,
37-
continuous: false, // false = automatically stop transcription the first time a pause is detected
37+
// continuous: false, // no longer supported
3838
outputElement: '#output' // CSS selector or DOM Element
3939
});
4040

41+
stream.on('data', function(data) {
42+
if(data.results[0] && data.results[0].final) {
43+
stream.stop();
44+
console.log('stop listening.');
45+
}
46+
});
47+
4148
stream.on('error', function(err) {
4249
console.log(err);
4350
});

speech-to-text/recognize-stream.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var contentType = require('./content-type');
2424
var qs = require('../util/querystring.js');
2525

2626
var OPENING_MESSAGE_PARAMS_ALLOWED = [
27-
'continuous',
2827
'inactivity_timeout',
2928
'timestamps',
3029
'word_confidence',
@@ -58,15 +57,14 @@ var QUERY_PARAMS_ALLOWED = ['customization_id', 'model', 'watson-token', 'X-Wats
5857
* @param {Object} [options.headers] - Only works in Node.js, not in browsers. Allows for custom headers to be set, including an Authorization header (preventing the need for auth tokens)
5958
* @param {String} [options.content-type='audio/wav'] - content type of audio; can be automatically determined from file header in most cases. only wav, flac, and ogg/opus are supported
6059
* @param {Boolean} [options.interim_results=true] - Send back non-final previews of each "sentence" as it is being processed. These results are ignored in text mode.
61-
* @param {Boolean} [options.continuous=true] - set to false to automatically stop the transcription after the first "sentence"
6260
* @param {Boolean} [options.word_confidence=false] - include confidence scores with results. Defaults to true when in objectMode.
6361
* @param {Boolean} [options.timestamps=false] - include timestamps with results. Defaults to true when in objectMode.
6462
* @param {Number} [options.max_alternatives=1] - maximum number of alternative transcriptions to include. Defaults to 3 when in objectMode.
6563
* @param {Array<String>} [options.keywords] - a list of keywords to search for in the audio
6664
* @param {Number} [options.keywords_threshold] - Number between 0 and 1 representing the minimum confidence before including a keyword in the results. Required when options.keywords is set
6765
* @param {Number} [options.word_alternatives_threshold] - Number between 0 and 1 representing the minimum confidence before including an alternative word in the results. Must be set to enable word alternatives,
6866
* @param {Boolean} [options.profanity_filter=false] - set to true to filter out profanity and replace the words with *'s
69-
* @param {Number} [options.inactivity_timeout=30] - how many seconds of silence before automatically closing the stream (even if continuous is true). use -1 for infinity
67+
* @param {Number} [options.inactivity_timeout=30] - how many seconds of silence before automatically closing the stream. use -1 for infinity
7068
* @param {Boolean} [options.readableObjectMode=false] - emit `result` objects instead of string Buffers for the `data` events. Does not affect input (which must be binary)
7169
* @param {Boolean} [options.objectMode=false] - alias for options.readableObjectMode
7270
* @param {Number} [options.X-Watson-Learning-Opt-Out=false] - set to true to opt-out of allowing Watson to use this request to improve it's services

0 commit comments

Comments
 (0)