4

I am trying to make an android based application whose one part is voice recognition. I have a very limited voice commands over which the application would work. So, I want to somehow limit the dictionary or create a new dictionary of words that would be used by the application, so that the app would have very good accuracy and a faster match. For eg. If I say "B" , the result can be "B","Be" or "Bee" , but my application should only look for "B" not any other similar sound. How to do it in android ?

Edit : I am new to android , only applied a basic google voice recognition till now by reading a tutorial on the net. Seriously, needs some hints to accomplish this task, so that I would not waste more time in searching for irrelevant things in future.

trojan
  • 79
  • 5
  • Given you had the data associated to phonems of Android's dictionary, it could be "easy" to remove some and only keep a subset of it. Otherwise, creating a list of phonems is a long and tedious task to get it accurate. – Snicolas Nov 24 '13 at 21:36
  • 1
    Can you post what you have tried that is not working? – Fiver Nov 24 '13 at 21:45
  • Actually, I am new to android. I dont know where to start to do this task. I searched a lot and finally posted it here, so that someone could direct me to correct path. – trojan Nov 24 '13 at 21:50
  • Can you post here your working code snippet where you are matching voice commands to application commands? Even if its not accurate as per your requirement its ok. Also please keep in mind that different people may pronounce 'B' slight differently. – Pranalee Nov 25 '13 at 06:25

2 Answers2

4

Android voice recognition will work both off-line and on-line. Just that when off-line, the recognition is not that good, and you do not have multiple choices of results. For on-line, Google voice recognizer will return an array of possible results, along with confidence levels, so if you have:

choice 1:  Bee     0.6522 confidence
choice 2:  Be      0.1    confidence
choice 3:  B       0.0    confidence

Your software can decide to ignore Bee (even with high confidence level), and choose the one you think is appropriate in your application.

Snippet of code:

/**
 *  in your Activity
 */
public void startVoice(View view) {

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,  RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Go on, say something...");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100);

    startActivityForResult(intent, 111);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == 111) {
        if (resultCode == RESULT_OK)
        {
            ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            float [] scores = data.getFloatArrayExtra(RecognizerIntent.EXTRA_CONFIDENCE_SCORES);
            //  TODO:  loop through possible matches, 
            //         and choose what you think is appropriate 
        }
    }
}  

Sproffer
  • 326
  • 2
  • 8
  • EXTRA_CONFIDENCE_SCORES only returning float array in which only 1st has some value between 0-1 rest all are 0.0. why is this so? – trojan Dec 09 '13 at 20:09
  • Looks like you get your code working. On the confidence level, yes, I knew that, but hope Google would fix it soon. Here, somebody else also ran into confidence problem: http://stackoverflow.com/questions/18765419/android-speechrecognizer-confidence-values-are-confusing – Sproffer Dec 12 '13 at 21:28
  • The official Android bug report for confidence level is http://code.google.com/p/android/issues/detail?id=23606 – Sproffer Dec 13 '13 at 02:31
1

Lol, I just realized that their voice recognition software is obviously cloud based. There will be no data you can use, all is in Google's data centers.

Here is some basic explanation : http://www.phonearena.com/news/The-secret-of-Googles-amazing-voice-recognition-revealed-it-works-like-a-brain_id39938

Snicolas
  • 37,840
  • 15
  • 114
  • 173