gcp SynthesizeLongAudio 返回 Rejected by impersonation_policy 错误

问题描述 投票:0回答:1

我正在尝试使用谷歌的

synthesizeLongAudio
API,遵循谷歌的快速入门页面

我正在向

https://texttospeech.googleapis.com/v1beta1/projects/${process.env.GOOGLE_PROJECT}/locations/global:synthesizeLongAudio?key=${process.env.API_KEY}

发送初始请求

然后我轮询返回的操作,直到获得

done: true
状态。

但是,此状态返回时出现以下错误:


{
name: 'projects/***/locations/global/operations/***', 
done: true,
error: {
   code: 16,
   message: 'Invalid authentication from policy (go/gcs-rpc-sp): Rejected by impersonation_policy (attempt to impersonate [email protected] -- if impersonation was unintentional, see go/dpci-faq#from-context-impersonation): Permission 'auth.impersonation.impersonateProdUser' not granted to [email protected], because no ALLOW or ALLOW_WITH_LOG rule includes that permission.; '

  }
}

什么可能导致此问题?

google-cloud-platform google-text-to-speech
1个回答
0
投票

我通过用

API_KEY
中的正确凭据替换
gcs service account
来修复此问题。

使用

node.js
客户端,我的通话现在如下所示:


import { v1beta1 } from '@google-cloud/text-to-speech';

const credentials = {
  client_email: process.env.GOOGLE_ACCOUNT_EMAIL!,
  private_key: process.env.GOOGLE_ACCOUNT_PRIVATE_KEY!
};


const ttsLongClient = new v1beta1.TextToSpeechLongAudioSynthesizeClient({
  credentials
});

...
const response = await ttsLongClient.synthesizeLongAudio(request);

它会返回正确的响应并将文件保存到存储桶中。

© www.soinside.com 2019 - 2024. All rights reserved.