错误:“请求有效负载大小超出限制:10485760字节。” &“请求有效负载大小超出限制:10485760字节”

时间:2020-09-03 12:14:27

标签: speech-recognition speech-to-text google-cloud-speech aws-transcribe

我们首次在点网Web项目中使用GCS语音API,通过对长音频文件的异步语音识别调用将音频转换为文本。 但是(超过1分钟)大于10 MB 的长音频文件不起作用。 甚至视频文件也无法转录。 我们已经尝试了以下代码。

 GoogleCredential googlecredetion;

  private async Task TranscribeFiles()
        {

        try
        {
            googlecredetion = await GoogleCredential.GetApplicationDefaultAsync();


            using (var stream = new FileStream(
               path: @"D:\Projects\ExtraDevelopement\WebAPI\WebSpeechAPI\aspspeechapi\LicenseFile\client_secret.json",
               mode: FileMode.Open, access: FileAccess.Read))
            {
                Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    scopes: new[] { "https://www.googleapis.com/auth/cloud-platform" },
                    user: "user",
                    taskCancellationToken: CancellationToken.None,
                    dataStore: new FileDataStore(folder: "AutomationServices"));
            }

            
            var speech = SpeechClient.Create();
            RecognitionConfig.Types.AudioEncoding EncodingType = RecognitionConfig.Types.AudioEncoding.Linear16;


            var longOperation = speech.LongRunningRecognize(new RecognitionConfig()
            {
                Encoding = EncodingType,
                SampleRateHertz = 48000,
                LanguageCode = "en-US",// "en",
                EnableWordTimeOffsets = true,
                AudioChannelCount = 2,
                Model =  "phone_call", 
            }, RecognitionAudio.FromFile(@"D:\Projects\ExtraDevelopement\WebAPI\WebSpeechAPI\aspspeechapi\AudioFiles\" + DropDownList3.SelectedValue + ""));
            //FromStorageUri("gs://audiovideo_bucket/export.wav"));
           

            longOperation = longOperation.PollUntilCompleted();
            var response = longOperation.Result;

            foreach (var result in response.Results)
            {

                foreach (var alternative in result.Alternatives)
                {

                    lit.Text += "<b>Transcript: {" + alternative.Transcript + "}</b><br/>";
                    lit.Text += "<b> Word count:{" + alternative.Words.Count + "}</b><br/>";
                    lit.Text += "<b>Word details:</b><br/>";
                    foreach (var item in alternative.Words)
                    {
                        lit.Text += "                 {" + item.Word + "}  --  ";
                        lit.Text += "  WordStartTime: {" + item.StartTime + "} - ";
                        lit.Text += "  WordEndTime: {" + item.EndTime + "}<br/>";
                    }
                }
                lit.Text += "<br/>";
            }
            }
catch (Exception ex)              
{lit.Text = ex.ToString();}
}

我什至尝试将文件上传到Google Cloud Storage的存储桶中并使用它,但也没有成功。 我一直在搜寻,到目前为止,关于如何增加或规避此限制我还没有得出任何结论。我正在使用免费试用帐户,但很高兴升级到付费订阅以增加此限制。据我了解,即使我使用付费订阅,该限制也会持续存在。

我遇到了以下两个错误:

  1. 状态(StatusCode = InvalidArgument,Detail =“在线音频超出持续时间限制。请使用GCS URI”)
  2. 状态(StatusCode = InvalidArgument,Detail =“请求有效负载大小超出限制:10485760字节”)

如果您有解决此问题的方法,请帮助我。

0 个答案:

没有答案