Search code examples
javaandroidspeech-recognitionmicrophone

Restricting the list of voice commands on Android to a predefined set


For Android, we have Google's voice input api's where we speak into the microphone and it outputs k most likely things that we said. Is there a way that, instead, we give voice input a set of valid "commands" or sentences and it outputs the most likely one?

For example, a list of valid commands would be:

"Play song" "Pause" "Next" "Previous"

However, no other words in the language would be considered as options.

Does anyone know how this could be accomplished?


Solution

  • You can archive that with CMUSphinx, it could take a grammar specifying the language to recognize as a parameter for decoder:

                c.setString("-jsgf","grammar.jsgf");
    

    The grammar is specified in JSGF format.