annyang icon indicating copy to clipboard operation
annyang copied to clipboard

Word Probability

Open revett opened this issue 9 years ago • 5 comments

Current Behavior

const didDetectSpeech = (possiblePhrases) => {
  console.log(possiblePhrases);
};

annyang.addCallback('result', didDetectSpeech);
annyang.start({
  continuous: false,
});

// Output: ['cat', 'mat', 'hat']

Possible Solution

Output changed to:

[
  {
    value: 'cat',
    probability: '0.9'
  },
  {
    value: 'mat',
    probability: '0.8'
  },
  {
    value: 'hat',
    probability: '0.7'
  },
]

Questions

  • Does the speech recognition engine return a probability for a given word?
  • Is there a way to limit the number of possible words handed back? E.g; top 5.

revett avatar Nov 11 '16 14:11 revett

Is anyone working on this? I think it's a good idea and would like to pick this up

danep93 avatar Nov 30 '16 20:11 danep93

  1. What is the use case? Why do you need this in your code? (it helps to plan a feature better, if we keep some use cases in mind).

  2. I would prefer an API that does not break existing behavior like the one suggested above. There are a lot of people using this right now, and this might break their existing code.


Does the speech recognition engine return a probability for a given word?

Yes, it does.

Is there a way to limit the number of possible words handed back? E.g; top 5.

It is currently limited to 5. Do you see a need to allow the developer to change this?


Thanks 👍

TalAter avatar Dec 01 '16 08:12 TalAter

Great 🎉

My use-case is around filtering out words which have a low probability, to make my application more reliable.

@TalAter I agree that the schema should be consistent. I can imagine two possible implementations:

  1. Release as a major version (v3.0.0) which follows the rules of semantic versioning.
  2. Add optional configuration to output verbose values. So the default output is still the same schema (an array of strings), but the verbose output will be an array of objects.

Thoughts?

revett avatar Dec 01 '16 16:12 revett

Any update on this? Still want to implement this whether through an API or just through a new major version

danep93 avatar Jan 16 '17 20:01 danep93

You could return "possiblePhrases" array just as usual, but add index zero [0] with the dictionary with probabilities. There would be no conflicts with the words in the array, because they are always strings, even "0" is the string.

And in the major 3.0.0 you could break the current behavior, just as everyone else's library does.

On Mon, 16 Jan 2017 at 23:48, Daniel Epstein [email protected] wrote:

Any update on this? Still want to implement this whether through an API or just through a new major version

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TalAter/annyang/issues/236#issuecomment-272958949, or mute the thread https://github.com/notifications/unsubscribe-auth/AB0iiNAB8vdmOA7lSJ-d0UJL5q_gJKNRks5rS9e6gaJpZM4Kv0kK .

caffeinum avatar Jan 16 '17 22:01 caffeinum