@@ -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