我尝试在我的 c# 项目中使用 Google.Cloud.TextToSpeech.V1
我注册了谷歌云,添加了一个项目 进行 gcloud init 并创建本地 ADC gcloud auth 应用程序默认登录 --impersonate-service-account [电子邮件受保护]
当我调试下面的代码时,在 client.SynthesizeSpeech 调用时出现错误
Google.Apis.Auth.OAuth2.Responses.TokenResponseException
HResult=0x80131500
Message=Error:"{
"error": {
"code": 404,
"message": "Not found; Gaia id not found for email [email protected]",
"errors": [
{
"message": "Not found; Gaia id not found for email xxx.com",
"domain": "global",
"reason": "notFound"
}
],
"status": "NOT_FOUND"
}
}
...
var client = new TextToSpeechClientBuilder
{
GrpcAdapter = RestGrpcAdapter.Default
}.Build();
SynthesisInput input = new SynthesisInput
{
Text = "Hello"
};
VoiceSelectionParams voiceSelection = new VoiceSelectionParams
{
LanguageCode = "en-US",
SsmlGender = SsmlVoiceGender.Male
};
AudioConfig audioConfig = new AudioConfig
{
AudioEncoding = AudioEncoding.Linear16,
SampleRateHertz = 22050,
};
SynthesizeSpeechResponse response = client.SynthesizeSpeech(input, voiceSelection, audioConfig);
using (Stream output = File.Create("c:/temp/sample.wav"))
{
// response.AudioContent is a ByteString. This can easily be converted into
// a byte array or written to a stream.
response.AudioContent.WriteTo(output);
}
我怎样才能摆脱这个错误。