You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java中Azure语音评估未返回增删项且未检测语音结束问题

Azure语音评估Java SDK使用问题

我在项目中用Azure语音评估Java SDK做发音质量评估,当前采用监听器实现方案,代码如下:

System.out.println("Starting recording with " + this.prompt);
PronunciationAssessmentConfig pronunciationAssessmentConfig = new PronunciationAssessmentConfig(this.getPrompt(),
        PronunciationAssessmentGradingSystem.HundredMark, PronunciationAssessmentGranularity.Phoneme, true);
//        PronunciationAssessmentConfig pronunciationAssessmentConfig = PronunciationAssessmentConfig.fromJson("{\"referenceText\":\"" + getPrompt() + "\",\"gradingSystem\":\"HundredMark\",\"granularity\":\"Phoneme\", \"miscue\":true}");
AudioConfig audioConfig = AudioConfig.fromDefaultMicrophoneInput();
SpeechUtil.SPEECH_CONFIG.setOutputFormat(OutputFormat.Detailed);

SpeechRecognizer speechRecognizer = new SpeechRecognizer(
        SpeechUtil.SPEECH_CONFIG,
        audioConfig);

pronunciationAssessmentConfig.applyTo(speechRecognizer);

speechRecognizer.startContinuousRecognitionAsync();

speechRecognizer.recognizing.addEventListener((o, speechRecognitionResultEventArgs) -> {
    try {
        final int words = speechRecognitionResultEventArgs.getResult().getText().split(" ").length;
        System.out.println("Recognizing: " + speechRecognitionResultEventArgs.getResult().getText());
        Platform.runLater(() -> this.controller.setSpoken(0, wordsReadToIndex(words)));
        System.out.println(words);
        System.out.println(pronunciationAssessmentConfig.getReferenceText());
        System.out.println(speechRecognitionResultEventArgs.getResult().getProperties().getProperty(PropertyId.SpeechServiceResponse_JsonResult));

        if (words >= pronunciationAssessmentConfig.getReferenceText().split(" ").length)
            speechRecognizer.stopContinuousRecognitionAsync();

    } catch (Throwable e) {
        e.printStackTrace();
    }
});

speechRecognizer.recognized.addEventListener((o, speechRecognitionEventArgs) -> {
    System.out.println("Recognized!");
    try {
        PronunciationAssessmentResult pronunciationAssessmentResult =
                PronunciationAssessmentResult.fromResult(speechRecognitionEventArgs.getResult());
        if (pronunciationAssessmentResult == null) return;
        System.out.println(pronunciationAssessmentResult.getAccuracyScore());
        String jsonString = speechRecognitionEventArgs.getResult().getProperties().getProperty(PropertyId.SpeechServiceResponse_JsonResult);
        System.out.println(jsonString);
        Platform.runLater(() -> this.complete(new Score(pronunciationAssessmentResult.getAccuracyScore().intValue(), JsonParser.parseString(jsonString))));
        speechRecognizer.stopContinuousRecognitionAsync();
    } catch (Throwable e) {
        e.printStackTrace();
    }
});

speechRecognizer.speechEndDetected.addEventListener((o, speechRecognitionEventArgs) -> {
    System.out.println("Speech end detected!");
});

现有问题

  • 已开启miscue参数,但无法检测发音中的遗漏(omissions)和插入(insertions)。测试时参考文本包含“of”但用户未发音,结果未识别出该遗漏。
  • speechEndDetected事件从未触发。

官方示例适配问题

尝试使用Azure官方示例中的pronunciationAssessmentWithMicrophoneAsync()方法,适配后仅返回服务超时错误:

CANCELED: ErrorCode=ServiceTimeout
CANCELED: ErrorDetails=Timeout: no recognition result received SessionId: 09f1a5492851429e81e4672c90144a37
CANCELED: Did you update the subscription info?

补充排查结果

经排查,该超时问题由嘈杂环境结合语音评估导致——无语音评估时,相同代码和环境可正常返回结果。


内容的提问来源于stack exchange,提问作者rowan-vr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 04:45:32