Wake up android phone with certain words like Hi Galaxy or Ok Google

后端 未结 2 947
情歌与酒
情歌与酒 2021-02-14 20:26

I would like to wake up an android phone by saying for example \"Hello George\", but could not find any useful answers. First of all , is android app needs to listen as service

2条回答
  •  余生分开走
    2021-02-14 20:33

    CMUSphinx has recently implemented continuous listening on Android platform. You can find the demo on the wiki page

    You can configure one or multiple keywords to listen to, the default keyword is "oh mighty computer". You also can configure the detection threshold. Currently supported languages are US English and few others (French, Spanish, Russian, etc). You can train your own model for your language.

    Listening is simple, you create a recognizer and just add keyword spotting search:

    recognizer = defaultSetup()
            .setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))
            .setDictionary(new File(modelsDir, "lm/cmu07a.dic"))
            .setKeywordThreshold(1e-5f)
            .getRecognizer();
    
    recognizer.addListener(this);
    recognizer.addKeywordSearch(KWS_SEARCH_NAME, KEYPHRASE);
    switchSearch(KWS_SEARCH_NAME);
    

    and define a listener:

    @Override
    public void onPartialResult(Hypothesis hypothesis) {
        String text = hypothesis.getHypstr();
        if (text.equals(KEYPHRASE))
          //  do something
    } 
    

提交回复
热议问题