Skip to content

Commit 44642a1

Browse files
committed
fixed more codeacy warnings
1 parent 90a268a commit 44642a1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • services/speech_to_text

services/speech_to_text/v1.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ module.exports = function (RED) {
126126
if (err || data.status === 'ERROR') {
127127
node.status({fill:'red', shape:'ring', text:'call to speech to text service failed'});
128128
node.error(err, msg);
129-
}
130-
else {
129+
} else {
131130
var r = data.results;
132131

133132
msg.transcription = '';
@@ -196,6 +195,8 @@ module.exports = function (RED) {
196195
// Now perform checks on the input and parameters, to make sure that all
197196
// is in place before the service is invoked.
198197

198+
var message = '';
199+
199200
// Credentials are needed for the service. They will either be bound or
200201
// specified by the user in the dialog.
201202
username = sUsername || this.credentials.username;
@@ -234,7 +235,7 @@ module.exports = function (RED) {
234235
// The input comes in on msg.payload, and can either be an audio file or a string
235236
// representing a URL.
236237
if (!msg.payload instanceof Buffer || !typeof msg.payload === 'string') {
237-
var message = 'Invalid property: msg.payload, can only be a URL or a Buffer.';
238+
message = 'Invalid property: msg.payload, can only be a URL or a Buffer.';
238239

239240
node.error(message, msg)
240241
return;
@@ -244,13 +245,14 @@ module.exports = function (RED) {
244245
// its also performed here as a double check.
245246
if (!(msg.payload instanceof Buffer)) {
246247
if (typeof msg.payload === 'string' && !urlCheck(msg.payload)) {
247-
var message = 'Invalid URL.';
248+
message = 'Invalid URL.';
248249

249250
node.error(message, msg)
250251
return;
251252
}
252253
} else {
253254
var f = fileType(msg.payload).ext;
255+
254256
switch (f) {
255257
case 'wav':
256258
case 'flac':
@@ -271,7 +273,7 @@ module.exports = function (RED) {
271273
temp.open({suffix: '.' + fileType(msg.payload).ext}, function (err, info) {
272274
if (err) {
273275
this.status({fill:'red', shape:'ring', text:'unable to open audio stream'});
274-
var message ='Node has been unable to open the audio stream';
276+
message = 'Node has been unable to open the audio stream';
275277

276278
node.error(message, msg);
277279
return;
@@ -288,7 +290,7 @@ module.exports = function (RED) {
288290
if (err) {
289291
this.status({fill:'red', shape:'ring',
290292
text:'unable to open url audio stream'});
291-
var message ='Node has been unable to open the url audio stream';
293+
message = 'Node has been unable to open the url audio stream';
292294

293295
node.error(message, msg);
294296
return;
@@ -302,7 +304,7 @@ module.exports = function (RED) {
302304
});
303305
} else {
304306
this.status({fill:'red', shape:'ring', text:'payload is invalid'});
305-
var message = 'Payload must be either an audio buffer or a string representing a url';
307+
message = 'Payload must be either an audio buffer or a string representing a url';
306308
node.error(message, msg);
307309
return;
308310
}

0 commit comments

Comments
 (0)