I am using the java code given below for decoding a wav file in my pocketsphinx android application .
Its working, but its sometimes not giving correct decoding results. Can I set any type of threshold for recognition accuracy with this code? And how?
public class PocketSphinxAsync extends AsyncTask<void, void,="" string=""> {
final Decoder[] d = new Decoder[1];
final String[] result = new String[1];
private Assets assets;
Context ctx;
public AsyncResponse delegate=null;
File assetsDir;
File ff;</void,>
PocketSphinxAsync(Contextc,Filef,AsyncResponseasyncResponse){this.delegate=asyncResponse;this.ctx=c;this.ff=f;}static{System.loadLibrary("pocketsphinx_jni");}@OverrideprotectedStringdoInBackground(Void...voids){try{FileInputStreamst;Configc;Assetsassets=newAssets(ctx);FileassetsDir=assets.syncAssets();st=newFileInputStream(ff);booleanisCancelled=false;c=Decoder.defaultConfig();c.setString("-hmm",newFile(assetsDir,"Model_full").getPath());c.setString("-dict",newFile(assetsDir,"Model_full.dic").getPath());c.setBoolean("-allphone_ci",true);c.setString("-lm",newFile(assetsDir,"Model_full.arpa").getPath());d[0]=newDecoder(c);d[0].startUtt();byte[]b=newbyte[4096];try{intnbytes;while((nbytes=st.read(b))>=0){ByteBufferbb=ByteBuffer.wrap(b,0,nbytes);//Notneededondesktopbutrequiredonandroidbb.order(ByteOrder.LITTLE_ENDIAN);short[]s=newshort[nbytes/2];bb.asShortBuffer().get(s);d[0].processRaw(s,nbytes/2,false,false);}}catch(IOExceptione){fail("Error when reading inputstream"+e.getMessage());}d[0].endUtt();result[0]=d[0].hyp().getHypstr();for(Segmentseg:d[0].seg()){//dosomethingwiththeresulthere}isCancelled=true;}catch(IOExceptione){e.printStackTrace();}returnresult[0];}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hai all,
I am using the java code given below for decoding a wav file in my pocketsphinx android application .
Its working, but its sometimes not giving correct decoding results. Can I set any type of threshold for recognition accuracy with this code? And how?
public class PocketSphinxAsync extends AsyncTask<void, void,="" string=""> {
final Decoder[] d = new Decoder[1];
final String[] result = new String[1];
private Assets assets;
Context ctx;
public AsyncResponse delegate=null;
File assetsDir;
File ff;</void,>
}