【发布时间】:2020-11-30 22:36:16
【问题描述】:
我已经学习了一堆关于 Google 语音转文本的教程,并且在本地都可以正常运行。我的设置是使用 websockets (socket.io) 在客户端 Angular 应用程序和对语音 API 进行服务器端调用的节点/快速后端之间进行通信。我正在使用streaming-recognize (https://cloud.google.com/speech-to-text/docs/streaming-recognize) 读取麦克风流并返回结果。
这完全可以在本地工作,但是在 gcloud app deploy 实例上运行它时我遇到了一个问题,因为我实际上没有安装 SoX 依赖项(通过 brew install sox 在本地完成。这是他们设置麦克风流示例的要求。
我认为我需要设置一个可以使用 SoX 配置的虚拟机实例,但我也觉得这似乎有点过头了 - 有替代方案吗?我确实尝试手动解析并将麦克风数据流作为 Uint8Array/ArrayBuffer chunkns 发送并取得了一些成功,但并不成功。我还阅读了一些关于处理用户麦克风流的非 SoX 方法的假设,但无济于事。例如,使用 recordrtc。
问题是 - 我需要做些什么才能让它在 gcloud 中工作?设置一个 vm 实例,安装 sox,然后使用它?或者有没有一种无 SoX 的方式来运行它? 欢迎指导!
这是我在 gcloud 上遇到的服务器错误 - 在我看来是因为它的路径上没有 SoX:
Error: spawn sox ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn sox',
path: 'sox',
spawnargs: [
'--default-device',
'--no-show-progress',
'--rate',
16000,
'--channels',
1,
'--encoding',
'signed-integer',
'--bits',
'16',
'--type',
'wav',
'-'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <APPNAME>@0.0.0 start:prod: `node server.js;`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <APPNAME>@0.0.0 start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-30T22_12_35_041Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <APPNAME>@0.0.0 start: `npm run start:prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <APPNAME>@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-30T22_12_35_074Z-debug.log
【问题讨论】:
标签: google-cloud-platform gcloud google-cloud-speech sox