谷歌云语音简单的问题没有回应



我有错误请求。我仍然不知道在哪里调用请求以及如何获取响应。我在哪里设置API密钥?

var initialize = new Google.Apis.Services.BaseClientService.Initializer();
initialize.ApiKey = "key";
var speech = new Google.Apis.Speech.v1.SpeechService(new Google.Apis.Services.BaseClientService.Initializer {
});
var recognizeReq = new Google.Apis.Speech.v1.Data.RecognizeRequest();
var recognitionConf = new Google.Apis.Speech.v1.Data.RecognitionConfig();
recognitionConf.LanguageCode = "pl-PL";
recognitionConf.SampleRateHertz = 16000;
recognitionConf.Encoding = "FLAC";
recogniseReq.Config = recognitionConf;
var aud = new Google.Apis.Speech.v1.Data.RecognitionAudio();
string path1 = @"c:output.flac";
//var bytesAudio = File.ReadAllBytes(path1);
aud.Uri = path1;
recognizeReq.Audio = aud;
var variable = speech.Speech.Recognize(recogniseReq);
variable.Key = "key";
//variable.OauthToken = 
variable.Execute();
Google.Apis.Speech.v1.Data.RecognizeResponse resp = new Google.Apis.Speech.v1.Data.RecognizeResponse();
var lista = resp.Results;

我更换了软件,现在我使用Google.Cloud.Speech.V1库我设法用NAudio保存了语音我试着向云端发送continuos请求,但不起作用

"waveFile.Write(e.Buffer,0,e.BytesRecorded(;

waveFile.Flush();
audio5 = RecognitionAudio.FromBytes(e.Buffer);
var result = client.LongRunningRecognizeAsync(config, audio5);

''

这解决了问题。缓冲区的问题持续时间较长。我和其他人一样陷入陷阱。在关于bug的争议中找到了解决方案(来自corse的谷歌;((https://github.com/GoogleCloudPlatform/dotnet-docs-samples/blob/95b32e683ba534883b8a7f3c979deee101ba3678/speech/api/Recognize/InfiniteStreaming.cs

最新更新