Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 在谷歌云上设置谷歌语音到文本-错误:spawn SoX enoint_Google Cloud Platform_Gcloud_Google Cloud Speech_Sox - Fatal编程技术网

Google cloud platform 在谷歌云上设置谷歌语音到文本-错误:spawn SoX enoint

Google cloud platform 在谷歌云上设置谷歌语音到文本-错误:spawn SoX enoint,google-cloud-platform,gcloud,google-cloud-speech,sox,Google Cloud Platform,Gcloud,Google Cloud Speech,Sox,我已经学习了一系列关于谷歌语音到文本的教程,并在本地运行良好。我的设置是使用websockets(socket.io)在客户端应用程序和对语音API进行服务器端调用的node/express后端之间进行通信。我正在使用streaming recognize()读取麦克风流并返回结果 这完全在本地运行,但在gcloud app deploy实例上运行它时,我遇到了一个问题,因为我没有实际安装SoX依赖项(通过brew install SoX在本地完成)。这是他们设置麦克风流示例的要求 我想我需要建

我已经学习了一系列关于谷歌语音到文本的教程,并在本地运行良好。我的设置是使用websockets(socket.io)在客户端应用程序和对语音API进行服务器端调用的node/express后端之间进行通信。我正在使用
streaming recognize
()读取麦克风流并返回结果

这完全在本地运行,但在
gcloud app deploy
实例上运行它时,我遇到了一个问题,因为我没有实际安装
SoX
依赖项(通过
brew install SoX
在本地完成)。这是他们设置麦克风流示例的要求

我想我需要建立一个虚拟机实例,我可以用SoX提供,但我也觉得这似乎有点过头了-有其他选择吗?我尝试过手动解析mic数据流,并将其作为Uint8Array/ArrayBuffer Chunks发送,取得了一些成功,但并不多。我还阅读了一些关于非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
Error:spawn sox enoint at Process.ChildProcess.\u handle.onexit(internal/child\u Process.js:267:19)at onerrorn(internal/child\u Process.js:469:16)at processtick和rejections(internal/Process/task\u queues.js:84:21)
在以下位置的ChildProcess实例上发出了“错误”事件:
在Process.ChildProcess.\u handle.onexit(内部/child\u Process.js:273:12)
在onErrorNT(内部/子进程js:469:16)
在处理和拒绝时(内部/process/task_queues.js:84:21){
errno:'enoint',
代码:'enoint',
系统调用:“生成sox”,
路径:“sox”,
产卵参数:[
“--默认设备”,
"无进展",,
"利率",,
16000,
"频道",,
1.
“--编码”,
“有符号整数”,
“--位”,
'16',
“--类型”,
“wav”,
'-'
]
}
npm错误!代码错误周期
npm错误!错误1
npm ERR!@0.0.0 start:prod:`node server.js`
npm错误!退出状态1
npm错误!
npm ERR!在@0.0.0 start:prod脚本中失败。
npm错误!这可能不是npm的问题。上面可能还有其他日志输出。
npm ERR!此运行的完整日志可在以下位置找到:
npm ERR!/root/.npm/_logs/2020-11-30T22_12_35_041Z-debug.log
npm错误!代码错误周期
npm错误!错误1
npm ERR!@0.0.0 start:`npm run start:prod`
npm错误!退出状态1
npm错误!
npm ERR!在@0.0.0启动脚本中失败。
npm错误!这可能不是npm的问题。上面可能还有其他日志输出。
npm ERR!此运行的完整日志可在以下位置找到:
npm ERR!/root/.npm/_logs/2020-11-30T22_12_35_074Z-debug.log

您正在尝试将Google Speech设置为文本,并希望将其部署到Google App Engine(gcloud App deploy)上

但是,Google Speech to Text具有依赖性,这需要在操作系统中安装Sox CLI

因此,您需要使用具有自定义运行时的App Engine Flexible environment。在Dockerfile中,您可以指定安装SOX CLI

我能够使用中提供的步骤和中的示例代码成功部署使用语音到文本API的App Engine Flex应用程序。请查看

**************更新**************

Dockerfile:

FROM gcr.io/google-appengine/nodejs

# Working directory is where files are stored, npm is installed, and the application is launched
WORKDIR /app

# Copy application to the /app directory.
# Add only the package.json before running 'npm install' so 'npm install' is not run if there are only code changes, no package changes
COPY package.json /app/package.json
RUN apt-get update
RUN  apt-get install -y sox
RUN npm install
COPY . /app

# Expose port so when the container is launched you can curl/see it.
EXPOSE 8080

# The command to execute when Docker image launches.
CMD ["npm", "start"]

请尝试上面的Dockerfile并根据您的需要进行调整,这是一个如何安装sox的示例。

非常感谢您的指导!看起来非常有希望。我已经做了一些研究,并尝试按照以下方式进行设置:我在使用它时遇到了一些困难-您有没有一个Dockerfile示例,我可以使用它来获得灵活的env运行,安装了SoX?我更新了我的答案,请查看一下。太棒了,谢谢!它已经整理了到目前为止我遇到的所有错误-现在得到了一个有点神秘的错误
SoX退出了,错误代码为2。
。在跟踪
gcloud应用程序日志尾部时,没有其他高于或低于此的错误。
。有一个google但是ca没有发现任何东西-我想如果你看到类似的东西,我会在这里询问。这些都在本地工作;可能缺少安装?啊,我认为sox错误代码是一种误导…可能是我的google creds没有授权。现在看。我的错误在我尝试访问麦克风流的位置。有人能想到可能缺少什么吗?一些明显的错误o怀疑:(-它在本地工作。有问题的代码:``const recorder=require('node-record-lpcm16');recorder.record({sampleRateHertz:16000,threshold:0,verbose:false,recordProgram:'rec',silent:'10.0',})。stream().on('error',(error)=>console.log('error with recorder.record',error)).pipe(recognizeStream);``输出:
记录错误。记录sox已退出,错误代码为2。