Я зарегистрировал облако Google, добавил проект
сделал инициализацию gcloud и создал локальный ADC с помощью
gcloud auth application-default login --impersonate-service-account xxx@gmail.com
когда я отлаживаю приведенный ниже код, при вызове client.SynthesizeSpeech выдает ошибку
Код: Выделить всё
Google.Apis.Auth.OAuth2.Responses.TokenResponseException
HResult=0x80131500
Message=Error:"{
"error": {
"code": 404,
"message": "Not found; Gaia id not found for email xxx@gmail.com",
"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);
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... ospeech-v1
Мобильная версия