4

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.

James Z
  • 12,209
  • 10
  • 24
  • 44
Manoj Deshpande
  • 311
  • 2
  • 18

2 Answers2

1

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);

Ram
  • 2,459
  • 1
  • 7
  • 14
1

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);
Ziad H.
  • 528
  • 1
  • 5
  • 20