Manoj Deshpande
Manoj Deshpande

Reputation: 311

How to enable word level Confidence for MS Azure Speech to Text Service

How to get word-level confidence for each word using MS Azure speech to text service? Currently, I am getting confidence value for sentence-level and I need word-level confidence for further processing.

Upvotes: 4

Views: 1226

Answers (2)

Ziad H.
Ziad H.

Reputation: 699

By using this code: setServiceProperty("wordLevelConfidence","true", ServicePropertyChannel.UriQueryParameter);

This is how I did it

SpeechConfig config = SpeechConfig.fromSubscription(speechSubscriptionKey, serviceRegion);

config.setServiceProperty("wordLevelConfidence","true", ServicePropertyChannel.UriQueryParameter);
config.setServiceProperty("format", "detailed", ServicePropertyChannel.UriQueryParameter); //you have to do it in this order

And this to get the results back

PropertyCollection properties = result.getProperties();
String property = properties.getProperty(PropertyId.SpeechServiceResponse_JsonResult);

Upvotes: 1

Ram
Ram

Reputation: 2754

You can retrieve the wordLevelConfidence by adding the ‘format=detailed’ & ‘wordLevelConfidence=true’ to the URI

For example, the language set to US English using the West US endpoint is: https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=detailed&wordLevelConfidence=true. enter image description here

If you use the SDK:

var config = SpeechConfig.FromSubscription(sub, "westeurope");
config.SetServiceProperty("wordLevelConfidence", "true", ServicePropertyChannel.UriQueryParameter);
//config.RequestWordLevelTimestamps(); in case you also want wordleveltimestamps
config.OutputFormat = OutputFormat.Detailed;

the word confidence values are not part of the result directly, Take a look at the below for complete result in JSON form. recognizer.Recognized += (s, e) => { var j = e.Result.Properties.GetProperty(PropertyId.SpeechServiceResponse_JsonResult);

Upvotes: 1

Related Questions