我使用此代码通过 Azure 认知服务转录 wav 文件。整个内容转录完毕后,我可以获得置信度分数吗? private static async Task<string> TranscribeWav(SpeechConfig config, string fileName) { var taskCompleteionSource = new TaskCompletionSource<int>(); var transcriptionStringBuilder = new StringBuilder(); using (var audioInput = AudioConfig.FromWavFileInput(fileName)) { using (var recognizer = new SpeechRecognizer(config, audioInput)) { // Subscribes to events. recognizer.Recognizing += (sender, eventargs) => { //TODO: Handle recognized intermediate result //Console.WriteLine(eventargs.Result.Text); }; recognizer.Recognized += (sender, eventargs) => { if (eventargs.Result.Reason == ResultReason.RecognizedSpeech) { transcriptionStringBuilder.Append(eventargs.Result.Text); } else if (eventargs.Result.Reason == ResultReason.NoMatch) { //TODO: Handle not recognized value } }; recognizer.Canceled += (sender, eventargs) => { if (eventargs.Reason == CancellationReason.Error) { //TODO: Handle error } if (eventargs.Reason == CancellationReason.EndOfStream) { Console.WriteLine($"End of stream ({transcriptionStringBuilder.ToString()})..."); } taskCompleteionSource.TrySetResult(0); };我的目的是将 wav 文件提交给认知服务进行转录。我是天蓝色的新手,想按顺序执行此操作,因此也请随时告诉我我的代码效率低下或错误。
1 回答
温温酱
TA贡献1752条经验 获得超4个赞
是的,为了获得置信度分数,您需要配置 SpeechConfig,如下所示,了解详细的输出格式。config.OutputFormat = OutputFormat.Detailed; 使用 Result.Best() 方法将返回最佳识别结果以及详细输出。详细输出显示置信度分数。
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报
0/150
提交
取消