0

这是来自https://www.npmjs.com/package/@google-cloud/speech的代码

   var speech = require('@google-cloud/speech');

   var client = speech({
      // optional auth parameters. 
   });

如何在使用 @google-cloud/speech 时传递我的 API 密钥进行身份验证?我阅读了文档并查看了示例,但他们没有谈论使用 API 密钥。有什么方法可以使用 API 密钥进行身份验证?

4

2 回答 2

3

您需要服务帐户密钥(它是 JSON keyFile)。去

Google speech api dashboard  ->  credentials   ->  create credentials 
->  Service account key   ->  Compute engine default   ->  download json file.

最后将它作为keyFile添加到config中,例如:

{ 
  projectId: 'my-project', 
  keyFile: './myKeyFile.json' 
};

来源: https ://bloggerbrothers.com/2017/01/15/the-complete-guide-to-enabling-speech-recognition-on-an-rpi3-in-nodejs/

于 2017-08-23T20:01:25.940 回答
0

我发现要在你的 nodejs 中使用 @google-cloud/speech 模块,你必须在 Google Cloud Platform 上创建一个项目,并且需要登录到你的谷歌帐户并将你的 projectid 作为参数提供给语音构造函数为了成功登录。

const speechClient = Speech({
     projectId: projectId
});

这将对您进行身份验证以调用 Google Speech API。我找不到使用 google API 密钥启用身份验证的文档。

于 2017-08-23T18:27:07.130 回答