jamsch / expo-speech-recognition

Speech Recognition for React Native Expo projects
MIT License
128 stars 11 forks source link

Confidence-score per word #18

Open raffiniert opened 2 months ago

raffiniert commented 2 months ago

Very nice library, thank you so much for all the efforts!

For my project, I would need a confidence score not only on the final result of f.e. a complete sentence, but on a per-word basis. Currently, the confidence score per word is always returned as 0.

Is there any way you could implement this in an upcoming release? I would buy you coffee/beer in large amounts for it :-D

jamsch commented 2 months ago

Hi @raffiniert, you can get the confidence scores per word segment through event.results[x].segments, however there's a few things to note:

On Android, your mileage may vary based on the recognition service you're using. This seems to be the only public Github repo that implements this functionality for RecognizerIntent.EXTRA_REQUEST_WORD_CONFIDENCE -- https://github.com/search?q=EXTRA_REQUEST_WORD_CONFIDENCE&type=code

Also of note for Android:

For iOS:

So to wrap it up, not really working for Android, but does work for iOS. Android will need upstream fixes for this feature to work. In the meantime if you do need to get this consistent across devices, there's two options you could explore:

raffiniert commented 2 months ago

man you're awesome. I don't have time to deep-dive rn but just wanted to thank you for your reply immediately.

Hope Android will fix it upstream soon and will look into the iOS-solution asap. Thanks again!