Skip to content

Commit b76256e

Browse files
committed
Added mute option for STT streaming
1 parent 5a0bb20 commit b76256e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Node-RED Watson Nodes for IBM Cloud
77

88
<a href="https://cla-assistant.io/watson-developer-cloud/node-red-node-watson"><img src="https://cla-assistant.io/readme/badge/watson-developer-cloud/node-red-node-watson" alt="CLA assistant" /></a>
99

10+
### New in version 0.6.6
11+
- Mute option for STT Node warning status when running in Streaming mode
12+
1013
### New in version 0.6.5
1114
- Endpoint can now be specified in Natural Language Classifier Node
1215

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-watson",
3-
"version": "0.6.5",
3+
"version": "0.6.6",
44
"description": "A collection of Node-RED nodes for IBM Watson services",
55
"dependencies": {
66
"async": "^1.5.2",

services/speech_to_text/v1.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
<label for="node-input-streaming-mode" style="width: 70%;"> Streaming Mode</label>
8989
</div>
9090

91+
<div class="form-row">
92+
<label>&nbsp;</label>
93+
<input type="checkbox" id="node-input-streaming-mute" style="display: inline-block; width: auto; vertical-align: top;">
94+
<label for="node-input-streaming-mute" style="width: 70%;"> Mute in Streaming Mode</label>
95+
</div>
96+
9197
<div class="form-row">
9298
<label>&nbsp;</label>
9399
<input type="checkbox" id="node-input-speakerlabels"style="display: inline-block; width: auto; vertical-align: top;"></input>
@@ -148,6 +154,7 @@
148154
is as per the WebSocket input for Speech To Text, with an action of either
149155
<code>start</code> or <code>stop</code> or an audio blob. No token is needed
150156
as the node takes care of that step.</p>
157+
<p>>The Mute option allows for the supression of session timeout messages.</p>
151158
<p>For more information about the Speech To Text service, read the <a href="https://www.ibm.com/watson/services/speech-to-text/">documentation</a>.</p>
152159
</script>
153160

@@ -542,6 +549,7 @@
542549
password: {value: ''},
543550
'payload-response' :{value: false},
544551
'streaming-mode' :{value: false},
552+
'streaming-mute' :{value: true},
545553
'default-endpoint' :{value: true},
546554
'service-endpoint' :{value: 'https://stream.watsonplatform.net/speech-to-text/api'}
547555
},

services/speech_to_text/v1.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = function (RED) {
2828
payloadutils = require('../../utilities/payload-utils'),
2929
sttV1 = require('watson-developer-cloud/speech-to-text/v1'),
3030
authV1 = require('watson-developer-cloud/authorization/v1'),
31+
muteMode = true;
3132
username = '', password = '', sUsername = '', sPassword = '',
3233
endpoint = '',
3334
sEndpoint = 'https://stream.watsonplatform.net/speech-to-text/api',
@@ -133,6 +134,8 @@ module.exports = function (RED) {
133134
function configCheck() {
134135
var message = '';
135136

137+
muteMode = config['streaming-mute'];
138+
136139
if (!config.lang) {
137140
message = 'Missing audio language configuration, unable to process speech.';
138141
} else if (!config.band) {
@@ -397,7 +400,10 @@ module.exports = function (RED) {
397400
// Force Expiry of Token, as that is the only Error
398401
// response from the service that we have seen.
399402
// report the error for verbose testing
400-
payloadutils.reportError(node,newMsg,d.error);
403+
if (!muteMode) {
404+
payloadutils.reportError(node,newMsg,d.error);
405+
}
406+
401407
token = null;
402408
getToken(determineService())
403409
.then(() => {
@@ -423,7 +429,9 @@ module.exports = function (RED) {
423429

424430
ws.on('error', (err) => {
425431
socketListening = false;
426-
payloadutils.reportError(node,newMsg,err);
432+
if (!muteMode) {
433+
payloadutils.reportError(node,newMsg,err);
434+
}
427435
// console.log('Error Detected');
428436
if (initialConnect) {
429437
//reject(err);
@@ -472,8 +480,9 @@ module.exports = function (RED) {
472480
//websocket.send(a.data);
473481
websocket.send(a.data, (error) => {
474482
if (error) {
475-
payloadutils.reportError(node,{},error);
476-
} else {
483+
if (!muteMode) {
484+
payloadutils.reportError(node,{},error);
485+
}
477486
}
478487
});
479488
}

0 commit comments

Comments
 (0)