Skip to content

Commit 9d4efd0

Browse files
committed
code tidy
1 parent 6d95d02 commit 9d4efd0

File tree

1 file changed

+9
-11
lines changed
  • services/speech_to_text

1 file changed

+9
-11
lines changed

services/speech_to_text/v1.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ module.exports = function (RED) {
198198
function payloadCheck(msg) {
199199
if (config['streaming-mode']) {
200200
return Promise.resolve();
201-
} else {
202-
return payloadNonStreamCheck(msg);
203201
}
202+
return payloadNonStreamCheck(msg);
204203
}
205204

206205
function processInputBuffer(msg) {
@@ -250,7 +249,7 @@ module.exports = function (RED) {
250249
function processInputStream(msg) {
251250
var tmp = msg.payload;
252251

253-
if ("string" === typeof msg.payload) {
252+
if ('string' === typeof msg.payload) {
254253
msg.payload = JSON.parse(tmp);
255254
if ( msg.payload.action &&
256255
'start' === msg.payload.action) {
@@ -394,15 +393,15 @@ module.exports = function (RED) {
394393
ws.send(JSON.stringify(startPacket));
395394
websocket = ws;
396395
socketCreationInProcess = false;
397-
//resolve();
396+
//resolve();
398397
});
399398

400399
ws.on('message', (data) => {
401400
// First message will be 'state': 'listening'
402401
console.log('-----------------------');
403402
console.log('Data Received from Input');
404403
console.log(data);
405-
var d = JSON.parse(data)
404+
var d = JSON.parse(data);
406405
var newMsg = {payload : JSON.parse(data)};
407406
node.send(newMsg);
408407
if (d && d.state && 'listening' === d.state){
@@ -469,11 +468,9 @@ module.exports = function (RED) {
469468
resolve();
470469
}
471470
});
472-
} else {
473-
if (audioData.action === 'stop') {
474-
websocket.send(JSON.stringify(audioData));
475-
socketListening = false;
476-
}
471+
} else if (audioData.action === 'stop') {
472+
websocket.send(JSON.stringify(audioData));
473+
socketListening = false;
477474
}
478475
}
479476
});
@@ -491,6 +488,7 @@ module.exports = function (RED) {
491488
return processSTTSocketStart(true);
492489
case 'stop':
493490
delay = 2000;
491+
// deliberate no break
494492
case 'data':
495493
// Add a Delay to allow the listening thread to kick in
496494
// Delays for Stop is longer, so that it doesn't get actioned
@@ -508,7 +506,7 @@ module.exports = function (RED) {
508506
})
509507
.then(() => {
510508
return Promise.resolve();
511-
})
509+
});
512510
return p;
513511
}
514512

0 commit comments

Comments
 (0)