我需要在计算机上安装GoogleSTT,但是代码不起作用,当我在计算机上而不在Buildroot系统上时,该代码可以工作。
我在运行时遇到此错误:
/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)
我可能丢失了一个软件包,但上面提到的所有内容均已正确安装,该代码已在我的计算机上经过测试,完全没有错误,
我尝试清理缓存,使用-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");
});
与或没有socket.io-client发生相同的错误。
由于我的BIOS没有RTC,所以我有一些硬编码的时间更新方法,因此google可能无法在我的计算机上获得正确的日期和时间,但我认为它甚至在执行任何操作之前就崩溃了
更多信息:
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'
_
系统
uname -a
Linux buildroot 4.14.29-v8 #1 SMP PREEMPT Mon Apr 29 13:48:27 UTC 2019 aarch64 GNU/Linux
由于缺少rtc,因此此处的日期已中断,要与节点服务器通信,我必须手动设置正确的日期和时间npm 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:我如何更新机器时钟
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')"
正在修复
修改
/root/node_modules/grpc/src/grpc_extension.js
的l:32binary.find(path.resolve(path.join(__dirname, '../package.json')));
对应的路径为
/root/node_modules/grpc/src/node/extension_binary/node-v57-linux-arm64-glibc/grpc_node.node
,这是正确的二进制路径试图忽略这一点将导致我缺少gRPC的功能并无法使用它:
/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)