I need to get GoogleSTT installed on a machine, but the code doesn't work, it works when i'm on my computer but not on my Buildroot system.
i got this error at runtime:
/root/node_modules/grpc/src/grpc_extension.js:57
throw e;
^
Error: File not found
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
(/root/node_modules/grpc/src/grpc_extension.js:32:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
I'm probably missing a package but all mentionned above are correctly installed, the code was tested on my computer with no error at all,
i tried cleaning cache, rebuild modules with -f
const io = require("socket.io-client");
const record = require('node-record-lpcm16');
const speech = require('@google-cloud/speech');
const client = new speech.SpeechClient();
var socket = io.connect("http://90.87.53.32:7700/");
const encoding = 'LINEAR16';
const sampleRateHertz = 16000;
const languageCode = 'fr-FR';
const request = {
config: {
encoding: encoding,
sampleRateHertz: sampleRateHertz,
languageCode: languageCode,
enableAutomaticPunctuation: true,
},
interimResults: true, // If you want interim results, set this to true
};
/*class Socket {
constructor() {
process.on('message', (msg) => {
this.set(msg);
});
process.send('loaded');
}
}*/
const recognizeStream = client
.streamingRecognize(request)
.on('error', console.error)
.on('data', data =>
socket.emit("lol", (
data.results[0] && data.results[0].alternatives[0]
? `Transcription: ${data.results[0].alternatives[0].transcript}\n`
: `\n\nReached transcription time limit, press Ctrl+C\n`))
);
socket.on('connect', function () {
record
.start({
sampleRateHertz: sampleRateHertz,
threshold: 0,
verbose: false,
recordProgram: 'arecord', // Try also "arecord" or "sox"
silence: '10.0',
})
.on('error', console.error)
.pipe(recognizeStream);
console.log('Listening, press Ctrl+C to stop.');
socket.emit('lol', "Message");
});
the same error occure with or w/o socket.io-client.
as my BIOS doesn't have a RTC, i have some hardcoded time update method so google may not be able to get correct date & time on my machine but i think it crashes even before executing anything
Here more infos:
npm
process.versions
{ http_parser: '2.8.1', node: '8.11.4', v8: '6.2.414.54', uv: '1.20.2', zlib: '1.2.11', ares: '1.14.0', modules: '57', nghttp2: '1.32.0', napi: '3', openssl: '1.0.2p' }
os.platform()
'linux'
os.arch()
'arm64'
_
Syst
uname -a
Linux buildroot 4.14.29-v8 #1 SMP PREEMPT Mon Apr 29 13:48:27 UTC 2019 aarch64 GNU/Linux
the date is broken here due to lack of rtc as i said, to communicate with node servers i have to manually set correct date & timenpm ls grpc
/root -- @google-cloud/speech@2.3.1 -- google-gax@0.25.6 +-- grpc@1.20.2 -- grpc-gcp@0.1.1 -- grpc@1.20.2 deduped
ls -lR node_modules/grpc/src/node
node_modules/grpc/src/node: total 1 drwxr-xr-x 3 root root 1024 Apr 30 2019 extension_binary node_modules/grpc/src/node/extension_binary: total 1 drwxr-xr-x 2 root root 1024 Apr 30 2019 node-v57-linux- arm64-glibc node_modules/grpc/src/node/extension_binary/node-v57-linux-arm64-glibc: total 13983 -rwxr-xr-x 1 root root 14318016 Apr 26 2019 grpc_node.node
plus: how i update machine's clock
date -s "$(wget -qSO- google.com 2>&1 | grep Date: | cut -d' ' -f5-8 | awk -v FS=' ' -v OFS=- '{print $3,$2,$1,$4}' | sed -r 's/\bJan\b/01/g; s/\bFeb\b/02/g; s/\bMar\b/03/g; s/\bApr\b/04/g; s/\bMay\b/05/g; s/\bJun\b/06/g; s/\bJul\b/07/g; s/\bAug\b/08/g; s/\bSep\b/09/g; s/\bOct\b/10/g; s/\bNov\b/11/g; s/\bDec\b/12/g' | sed 's/./ /11')"
Fixing in progress
Actions done:
Modifying l:32 of
/root/node_modules/grpc/src/grpc_extension.js
binary.find(path.resolve(path.join(__dirname, '../package.json')));
The corresponding path is
/root/node_modules/grpc/src/node/extension_binary/node-v57-linux-arm64-glibc/grpc_node.node
which is the correct binary pathtrying to ignore this will lead me to lack of functions from gRPC and enable to use it:
/root/node_modules/grpc/src/client_interceptors.js:664 [grpc.opType.SEND_MESSAGE]: [grpc.opType.SEND_INITIAL_METADATA], ^ TypeError: Cannot read property 'SEND_MESSAGE' of undefined at Object.<anonymous> (/root/node_modules/grpc/src/client_interceptors.js:664:16) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object.<anonymous> (/root/node_modules/grpc/src/client.js:35:27) at Module._compile (module.js:652:30)