我目前正在使用Google Cloud对Text SDK for c#的演讲。我正在使用的nuget包是Google.Cloud.Speech.V1P1Beta1。我试图从较长的视频的语音隔离中受益,但是无论音频中有多少个扬声器,它都会在所有单词的扬声器标签中始终返回0。以下是我的代码
var longOperation = speech.LongRunningRecognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
DiarizationSpeakerCount = 2,
EnableSpeakerDiarization = true,
SampleRateHertz = 16000,
LanguageCode = "en",
}, RecognitionAudio.FromFile("testRecording.wav"));
longOperation = longOperation.PollUntilCompleted();
var response = longOperation.Result;
Console.WriteLine("Response received successfully.");
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
foreach (var word in alternative.Words)
{
Console.WriteLine($"{word.Word}: {word.SpeakerTag}");
}
}
}