java - File not found exception? (Voice recog) -


sorry long question, have been stuck on month, , want provide detail possible...its file not found exception in simple library... :)

i getting file not found exception on variances file:

enter image description here

i do, however, have variances file:

enter image description here

i trying implement voice recognition in background service, can detect when user says word hello (using pocketsphinx).

the problem happens in method: createsphinxdir();

here service:

 @override     public void oncreate() {         super.oncreate();        setuprecog();          }      private void setuprecog() {     string sphinxdir = createsphinxdir();     log.v(tag, "about create setup");     if (sphinxdir != null) {         try {              log.v(tag, "setting up! :)");             mspeechrecognizer = defaultsetup()                     .setacousticmodel(new file(sphinxdir, "en-us-ptm"))                     .setdictionary(new file(sphinxdir, "hello.dict"))                     .setboolean("-allphone_ci", true) //what                     .getrecognizer();             mspeechrecognizer.addlistener(this);              log.v(tag, "added listener");              if ((new file(sphinxdir + file.separator + "command.gram")).isfile()) {                 mspeechrecognizer.addkeywordsearch("hello",                         new file(sphinxdir + file.separator + "command.gram"));                  log.v(tag, "added keyword search! :)");             }              // or wherever appropriate             mspeechrecognizer.startlistening("wakeup"); //is correct?             log.v(tag, "started listening");          } catch (ioexception e) {              log.v("error", tag);          }     } }   string createsphinxdir() {     sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(this);     string sphinxdir = prefs.getstring("sphinx", null);     if (sphinxdir == null) {         assets assets;         log.v(tag, "assets not synced, should sync now:");         try {             log.v(tag, "in try block!");             assets = new assets(this);             file sphinxdirfile = assets.syncassets();             log.v(tag, "syncing assets...should set listener");             if (sphinxdirfile != null) {                 sphinxdir = sphinxdirfile.getabsolutepath();                 sharedpreferences.editor editor = prefs.edit();                 editor.putstring("sphinx", sphinxdir);                 editor.commit();                 log.v(tag, "set listener");              }else{                 log.v(tag, "sphinxdirfile null!");             }         } catch (ioexception e) { //this place getting error!             e.printstacktrace();             log.d(tag, e.tostring());         }     }     return sphinxdir; } 

i have call methods (onpartialresult, onresult, etc.) never called.

earlier getting exception saying variances .md5 file didn't exist, put space in between variances , .md5, getting error, , don't know why...

please let me know,

ruchir

earlier getting exception saying variances .md5 file didn't exist, put space in between variances , .md5, getting error, , don't know why...

you should not such things, causes problems, instead need follow documentation:

the standard way ship resource files application in android put them in assets/ directory of project. in order make them available pocketsphinx files should have physical path, long within .apk don't have one. assets class pocketsphinx-android provides method automatically copy asset files external storage of target device. edu.cmu.pocketsphinx.assets#syncassets synchronizes resources reading items assets.lst file located on top assets/. before copying matches md5 checksums of asset , file on external storage same name if such exists. actualy copying if there incomplete information (no file on external storage, no of 2 .md5 files) or there hash mismatch. pocketsphinxandroiddemo contains ant script generates assets.lst .md5 files, assets.xml.

please note if ant build script doesn't run in build process, assets might out of sync. make sure script runs during build.

to integrate assets sync in application following

include app/asset.xml build file demo application application. edit build.gradle build file run assets.xml:

  ant.importbuild 'assets.xml'   prebuild.dependson(list, checksum)   clean.dependson(clean_assets) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -