c#中的代码:
namespace GoogleSpeechConsole
{
class Program
{
static void Main(string[] args)
{
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
SampleRateHertz = 16000,
LanguageCode = "en",
}, RecognitionAudio.FromFile("myAudioFile.flac"));
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine(alternative.Transcript);
}
}
}
}
}
我尝试了各种格式和设置,如raw,wave和flac。但没有运气。 我在以下函数中的CloudSpeechGrpc.cs中得到了相同的错误:
public virtual global::Google.Cloud.Speech.V1.RecognizeResponse Recognize(global::Google.Cloud.Speech.V1.RecognizeRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_Recognize, null, options, request);
}
并出现以下错误:
Grpc.Core.RpcException:'状态(StatusCode =内部,详细信息="已收到 RST_STREAM,错误代码为2")'