【问题标题】:Not able to set google speech constructor using credential options无法使用凭证选项设置谷歌语音构造函数
【发布时间】:2020-02-02 06:56:21
【问题描述】:

您好,我正在尝试不使用 json 方法并使用凭据选项来启动 gcloud 语音客户端。

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

         const client = new speech.SpeechClient({credentials:{private_key : "", client_email: ""}}});

但这给了我错误:3 INVALID_ARGUMENT:请求包含无效参数错误。

我以同样的方式使用了对话流和其他服务,并且工作正常,如果我在这里遗漏了什么,请告知。

【问题讨论】:

    标签: google-speech-api google-speech-to-text-api


    【解决方案1】:

    你可以试试:

       const speech = require('@google-cloud/speech');
       const config = { projectId: 'your-project', keyFilename:'key.json'};
       const client = new speech.SpeechClient(config);
    

    在你的代码中你有一个额外的},这对我有用。

       const client = new speech.SpeechClient({credentials:{private_key : private_key, client_email: client_email}});
    

    【讨论】:

    • 谢谢,const client = new speech.SpeechClient({credentials:{private_key : private_key, client_email: client_email}}); 为您工作吗?
    • 是的,正在为我工​​作,我不知道你为 private_key 和 client_email 传递了什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-12-17
    • 2022-12-13
    相关资源
    最近更新 更多