【问题标题】:Can I retrieve the confidence of the transcription from Azure Cognitive Services?我可以从 Azure 认知服务中检索转录的置信度吗?
【发布时间】:2019-07-15 16:32:53
【问题描述】:

我正在使用此代码通过 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);
                };

                recognizer.SessionStarted += (sender, eventargs) =>
                {
                    //Started recognition session  
                };

                recognizer.SessionStopped += (sender, eventargs) =>
                {
                    //Ended recognition session  
                    taskCompleteionSource.TrySetResult(0);
                };

                // Starts continuous recognition. Uses StopContinuousRecognitionAsync() to stop recognition.  
                await recognizer.StartContinuousRecognitionAsync().ConfigureAwait(false);

                // Waits for completion.  
                // Use Task.WaitAny to keep the task rooted.  
                Task.WaitAny(new[] { taskCompleteionSource.Task });

                // Stops recognition.  
                await recognizer.StopContinuousRecognitionAsync();
            }
        }

        return transcriptionStringBuilder.ToString();
    }

我的意图是将 wav 文件提交给认知服务进行转录。我是 azure 新手,想按顺序执行此操作,因此也请随时告诉我我的代码效率低下或错误。

【问题讨论】:

    标签: c# azure-cognitive-services


    【解决方案1】:

    是的,要获得置信度分数,您需要如下所示配置 SpeechConfig 以获得详细的输出格式。 config.OutputFormat = OutputFormat.Detailed; 使用 Result.Best() 方法,该方法将返回具有详细输出的最佳识别。详细输出有要显示的置信度分数。

    请参考以下Speech recognition samples,希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-06
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 2023-03-28
      • 2014-08-24
      • 1970-01-01
      • 2021-12-24
      相关资源
      最近更新 更多