开发者

Voice recognition, is there a way I can determine what the user says, possibly via regex?

开发者 https://www.devze.com 2023-02-09 22:40 出处:网络
I\'m using the voice recognition feature in android, I can speak into my device and be presented with a list of possible words.

I'm using the voice recognition feature in android, I can speak into my device and be presented with a list of possible words.

When I say "start" it gives me the following words it thought it heard :

  1. stocks
  2. stock
  3. stop
  4. start
  5. stops
  6. starks

That list will depend on user a开发者_StackOverflowccents amongst various other factors. Is there an easy way I can check that list for a specific word?

If a user issues the command "start" or "stop" I need to be able to tell the difference between the two commands.

My initial thought was to use a regex to check for "sta" or "sto" in any of the responses, is there a more effective way?


Normally, I'd suggest that you generate a Soundex for every word you get back, score the entire list against the Soundexes of the words you're looking for as a fraction of characters matched and use those scores to decide which word is more likely to be a match.

For example, start encodes to S363 and stop encodes to S310. Scoring those against the words as a percentage of characters matched results in the following table:

Word    Soundex  S363   S310
----    -------  ----   ----
stocks  S320     0.50   0.75
stock   S320     0.50   0.75
stop    S310     0.50   1.00
start   S363     1.00   0.50
stops   S312     0.50   0.75
starks  S362     0.75   0.50
                 ----   ----
Average Score    0.63   0.71

Unfortunately, this comes up with the wrong answer (the probability that you said stop is higher even though you know you said start) because your two words have a lot in common. When the recognizer matches one of your target words and confuses it with another in the same go-'round, you really have no way of knowing which one the speaker actually said.

You can work around this by selecting words that aren't so similar, like go and stop or begin and end. Then you can ditch the Soundex entirely and just look for your target words in the returned list. You'll have to watch for this in other localizations for your application, because other languages can have similar problems (e.g., French, which has allez and arrêtez).

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消