Im currently building a feature of my app that should allow the user to say a phrase which will then be compared with a phrase said by another user to determine if they are equal. I am getting back results from the Speech Recognizer Intent as follows.
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
When I tried it by saying "Testing 123" I got back an array populated with "Testing 123, Testing one two three, Piscon 123"
Is there a way I can only extract the most accurate phrase from the result such as just "Testing 123" ? When I do a search with Google Now only the most accurate representation of what I said is returned so I'm wondering if this functionality can be achieved.
I tried "How high can you jump" and got this result. Is there a way to somewhat determine the start of the next sentence so I can extract the most positive result?
If you'd like to get just the most accurate, you'll want to also grab
EXTRA_CONFIDENCE_SCORES
. You'll want to find the highest confidence score and the corresponding String value.From the documentationAnd confidence scores: