gpt4 book ai didi

php - 如何在 PHP 应用程序中验证 Google Cloud Speech-To-Text 客户端?

转载 作者:行者123 更新时间:2023-12-04 00:52:44 25 4
gpt4 key购买 nike

对于 PHP 应用程序中的 Cloud Speech-To-Text 客户端身份验证,我使用以下内容:

 $credentials = 'C:\cred.json';
$client=new SpeechClient(['credentials'=>json_decode(file_get_contents($credentials), true)]);

由于某些原因我收到错误:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Clienterror: POST https://oauth2.googleapis.com/token resulted in a 400 Bad Request response:{"error":"invalid_scope","error_description":"Invalid OAuth scope orID token audience provided."}

上述身份验证方法在 Text-To-Speech API 中完美运行。

$credentials = 'C:\cred.json';
$client = new TextToSpeechClient(['credentials' => json_decode(file_get_contents($credentials), true)]);

有什么问题/缺失?

最佳答案

通过更新 Auth 模块(在 Vendor 文件夹中)解决了这个问题。只需将您的 Auth 版本更改为您的 composer.json 文件中的最新版本即可。

{
"require": {
"google/auth": "1.14.3",
"google/cloud-text-to-speech": "^0.5.0",
"google/cloud-speech": "^1.3",
"google/protobuf": "^3.14",
"phpmailer/phpmailer": "^6.1",
"google/apiclient": "2.5"
}
}

一旦完成,我就跑

composer update

在适当目录中的命令行中。现在可以了。

关于php - 如何在 PHP 应用程序中验证 Google Cloud Speech-To-Text 客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65191899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com