【问题标题】:Google Cloud speech simple problems with no response谷歌云语音简单问题无响应
【发布时间】:2021-06-11 23:29:13
【问题描述】:

我有错误请求。我仍然不知道在哪里调用请求以及如何获取响应。我在哪里设置 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


    【解决方案1】:

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

    ''' waveFile.Write(e.Buffer, 0, e.BytesRecorded);

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

    '''

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-07-11
        • 1970-01-01
        • 2023-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-08
        • 1970-01-01
        相关资源
        最近更新 更多