Google.cloud.speech.v1.RecognizeRequest无法识别存储桶?

时间:2017-08-08 03:49:59

标签: google-cloud-platform

我按照社区谷歌云平台连接到twilio以捕获语音呼叫并保存到存储桶。但是,由于以下错误消息,它无法转换语音。有谁知道为什么 google.cloud.speech.v1.RecognizeRequest无法识别存储桶?

(网址:https://cloud.google.com/community/tutorials/cloud-functions-twilio-voice-record

  

“错误:.google.cloud.speech.v1.RecognizeRequest#bucket不是字段:undefined       在错误(本机)       在MessagePrototype.set(/user_code/node_modules/@google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2490:35)       在MessagePrototype.set(/user_code/node_modules/@google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2483:38)       在留言(/user_code/node_modules/@google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2411:34)       在序列化(/user_code/node_modules/@google-cloud/speech/node_modules/grpc/src/node/src/protobuf_js_5_common.js:81:23)       在ServiceClient.Client.makeUnaryRequest(/user_code/node_modules/@google-cloud/speech/node_modules/grpc/src/node/src/client.js:530:17)       at apply(/user_code/node_modules/@google-cloud/speech/node_modules/lodash/lodash.js:499:17)       在ServiceClient.wrapper [作为识别](/user_code/node_modules/@google-cloud/speech/node_modules/lodash/lodash.js:5356:16)       at /user_code/node_modules/@google-cloud/speech/src/v1/speech_client.js:111:41       at timeoutFunc(/user_code/node_modules/@google-cloud/speech/node_modules/google-gax/lib/api_callable.js:177:12)“
   时间戳:“2017-08-07T17:27:02.601Z”

1 个答案:

答案 0 :(得分:1)

我用以下代码解决了这个问题:

var config = {
  sampleRateHertz: 8000,
  encoding: 'LINEAR16',
  languageCode: 'en-US'


};
var uri = `gs://${object.bucket}/${object.name}`;
var audio = {
  uri : uri
 };
var request = {
  config: config,
  audio: audio
};

// Transcribe the audio file
return speech.recognize(request)

顺便说一下:我还必须注释掉下面的'注释'功能才能让它工作