How to access confidence score of speech recognition results in JavaScript

Gunwoo Kim 20 Reputation points
2025-02-19T23:27:08.23+00:00

I'm using real-time Azure AI Speech recognition with automatic language recognition. I would like to filter out low-confidence recognition results, which mostly caused by background noise or unclear microphone input. I'm using Node.js SDK.

It seems there are two fields - confidence and language recognition confidence.

  1. Confidence - It seems not exposed on Node.js API. Is there any workaround?
  2. Language confidence - While it's exposed, its value is always 0.

Can you help me with this?

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,927 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prashanth Veeragoni 640 Reputation points Microsoft Vendor
    2025-02-20T05:28:08.9466667+00:00

    Hi Gunwoo Kim,

    Thank you for reaching out to Microsoft Q&A forum!

    Yes, you are correct that the confidence score of speech recognition results is not directly exposed in the Azure AI Speech SDK for Node.js. However, there are some workarounds and best practices you can use to filter out low-confidence results.

    Confidence Score: Azure AI Speech SDK (JavaScript/Node.js) does not currently expose the confidence score of the recognized speech result.

    This is a limitation compared to the Python or C# SDK, which does provide confidence scores.

    Language Recognition Confidence: This field is exposed but is always returning 0, which seems like an issue with how it's being retrieved or a limitation in the API response.

    Workarounds:

    Using Detailed Recognition Mode (JSON Response): Although the confidence score is not directly available in the Node.js SDK, you can enable detailed output and extract it manually.

    Steps to Enable Confidence Scores in JSON Output:

    Use speech config with setProperty to enable detailed JSON output.

    Parse the JSON response to extract the confidence score.

    The jsonResult contains detailed recognition results, including confidence scores.

    Extract NBest[0].Confidence (highest-ranked hypothesis).

    Apply filtering: Accept results only if confidence > 0.7.

    Please refer to the below document - Node.js speech SDK attaching for your reference.

    https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-sdk

    Hope this helps. Do let us know if you any further queries.  

    ------------- 

    If this answers your query, do click Accept Answer and Yes for was this answer helpful.

    Thank you.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.