IBM/speech-to-text-code-pattern

Help setting up this API Please

theancients89 opened this issue · 2 comments

image
This is the errors I get when running the script, my log is as follows:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.14.12
3 info using node@v10.24.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0prestart: @ibm-watson/speech-to-text-code-pattern@0.1.0
6 info lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0
start: @ibm-watson/speech-to-text-code-pattern@0.1.0
7 verbose lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0start: unsafe-perm in lifecycle true
8 verbose lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0
start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/bertos/readcall/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
9 verbose lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0start: CWD: /home/bertos/readcall
10 silly lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0
start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0start: Returned: code: 1 signal: null
12 info lifecycle @ibm-watson/speech-to-text-code-pattern@0.1.0
start: Failed to exec start script
13 verbose stack Error: @ibm-watson/speech-to-text-code-pattern@0.1.0 start: node server.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid @ibm-watson/speech-to-text-code-pattern@0.1.0
15 verbose cwd /home/bertos/readcall
16 verbose Linux 3.10.0-1160.31.1.el7.x86_64
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v10.24.1
19 verbose npm v6.14.12
20 error code ELIFECYCLE
21 error errno 1
22 error @ibm-watson/speech-to-text-code-pattern@0.1.0 start: node server.js
22 error Exit status 1
23 error Failed at the @ibm-watson/speech-to-text-code-pattern@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@theancients89 Hey! I had this issue too while setting it up. I am not sure if it will work for you, but you could give it a try:

Just remove vcapCredentials?.apikey and skitJson?.apikey from the lines:

const apikey =
  process.env.SPEECH_TO_TEXT_APIKEY || process.env.SPEECHTOTEXT_APIKEY || vcapCredentials?.apikey || skitJson?.apikey;

and

const url = process.env.SPEECH_TO_TEXT_URL || process.env.SPEECHTOTEXT_URL || vcapCredentials?.url || skitJson?.url;

So, finally, your lines would be:

const apikey = process.env.SPEECH_TO_TEXT_APIKEY || process.env.SPEECHTOTEXT_APIKEY;
const url = process.env.SPEECH_TO_TEXT_URL || process.env.SPEECHTOTEXT_URL;

I had done this a while back, I can't remember clearly, and apparently this error was gone.
I am not sure, but I usually see variable?.attribute syntax in TS files, and not in JS files.

nodes 10 is no longer supported. You should update.

The code using ?. requires node.js 14 or later. If you need to use out-of-support (10) or maintenance (12) versions, you can try the above workaround in your own clone or fork, but some other folks will want to keep the current vcap and skitJson code.

package.json suggests...
"engines": {
"node": "14.x"
},