Menu

Pocketsphinx on Android without keyword-activation search

Help
Alessandro
2016-02-18
2016-02-18
  • Alessandro

    Alessandro - 2016-02-18

    Hi,
    I integrated the library pocketsphinx-android-5prealpha lib.jar-no in my project so as described in the Wiki, everything works fine.
    I need some clarification on its functioning.
    In particular, I wanted to know you can start the reconnaissance without udare a keyword? I mean you can directly start continuous reconnaissance as well as works OpenEars on Ios? so that the user can continue to inpartire commands without having to utter the keyword-activation?
    I hope someone can help me, rigraziandovi advance I offer my greetings.

     
    • Nickolay V. Shmyrev

      Yes, you can. You can select any type of search from the start in the code.

       
  • Alessandro

    Alessandro - 2016-02-18

    Nicolay Hello and thanks for the reply.
    Forgive me but I can not understand this passage.
    This I have to do it in setupRecognizer?

        private void setupRecognizer(File assetsDir) throws IOException {
            // The recognizer can be configured to perform multiple searches
            // of different kind and switch between them
    
            recognizer = defaultSetup()
                    .setAcousticModel(new File(assetsDir, "en-us-ptm"))
                    .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
    
                    // To disable logging of raw audio comment out this call (takes a lot of space on the device)
                    .setRawLogDir(assetsDir)
    
                    // Threshold to tune for keyphrase to balance between false alarms and misses
                    .setKeywordThreshold(1e-45f)
    
                    // Use context-independent phonetic search, context-dependent is too slow for mobile
                    .setBoolean("-allphone_ci", true)
    
                    .getRecognizer();
            recognizer.addListener(this);
    
            /** In your application you might not need to add all those searches.
             * They are added here for demonstration. You can leave just one.
             */
    
            // Create keyword-activation search.
    
            recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);
    
            // Create grammar-based search for selection between demos
            File menuGrammar = new File(assetsDir, "menu.gram");
            recognizer.addGrammarSearch(MENU_SEARCH, menuGrammar);
    
            // Create grammar-based search for digit recognition
            File digitsGrammar = new File(assetsDir, "digits.gram");
            recognizer.addGrammarSearch(DIGITS_SEARCH, digitsGrammar);
    
            // Create language model search
            File languageModel = new File(assetsDir, "weather.dmp");
            recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);
    
            // Phonetic search
            File phoneticModel = new File(assetsDir, "en-phone.dmp");
            recognizer.addAllphoneSearch(PHONE_SEARCH, phoneticModel);
    
    
    
        }
    

    How should I change it to get recognition without keyword-activation search?
    Thank you.

     

    Last edit: Alessandro 2016-02-18
  • Nickolay V. Shmyrev

           new AsyncTask<Void, Void, Exception>() {
                @Override
                protected Exception doInBackground(Void... params) {
                    try {
                        Assets assets = new Assets(PocketSphinxActivity.this);
                        File assetDir = assets.syncAssets();
                        setupRecognizer(assetDir);
                    } catch (IOException e) {
                        return e;
                    }
                    return null;
                }
    
                @Override
                protected void onPostExecute(Exception result) {
                    if (result != null) {
                        ((TextView) findViewById(R.id.caption_text))
                                .setText("Failed to init recognizer " + result);
                    } else {
                        switchSearch(FORECAST_SEARCH);
                    }
                }
            }.execute();
    
    ......
    
    private void setupRecognizer(File assetsDir) throws IOException {
            recognizer = defaultSetup()
                    .setAcousticModel(new File(assetsDir, "en-us-ptm"))
                    .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
    
                    // To disable logging of raw audio comment out this call (takes a lot of space on the device)
                    .setRawLogDir(assetsDir)
    
                    .getRecognizer();
            recognizer.addListener(this);
            // Create language model search
            File languageModel = new File(assetsDir, "weather.dmp");
            recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);
        }
    
     
  • Alessandro

    Alessandro - 2016-02-18

    Thank you so much great !

     

Log in to post a comment.