The grammer I used in the training was based on sentences -it's like sentence1|sentence2 and so on- and it worked well when I was training the acoustic model ... but the results of the recognizer gives me words why? and is there a way that I can make the recognizer wait more before it stops taking the input from the user?
Is there more clear documentation for using pocket sphinx for android than the current one?
packageedu.cmu.pocketsphinx.demo;importandroid.Manifest;importandroid.app.Activity;importandroid.content.pm.PackageManager;importandroid.os.AsyncTask;importandroid.os.Bundle;importandroid.support.v4.app.ActivityCompat;importandroid.support.v4.content.ContextCompat;importandroid.widget.TextView;importandroid.widget.Toast;importjava.io.File;importjava.io.IOException;importjava.util.HashMap;importedu.cmu.pocketsphinx.Assets;importedu.cmu.pocketsphinx.Hypothesis;importedu.cmu.pocketsphinx.RecognitionListener;importedu.cmu.pocketsphinx.SpeechRecognizer;importedu.cmu.pocketsphinx.SpeechRecognizerSetup;importstaticandroid.widget.Toast.makeText;publicclassPocketSphinxActivityextendsActivityimplementsRecognitionListener{privatestaticfinalStringTEST_SEARCH="test";/*Usedtohandlepermissionrequest*/privatestaticfinalintPERMISSIONS_REQUEST_RECORD_AUDIO=1;privateSpeechRecognizerrecognizer;privateHashMap<String,Integer>captions;@OverridepublicvoidonCreate(Bundlestate){super.onCreate(state);captions=newHashMap<String,Integer>();captions.put(TEST_SEARCH,R.string.test_caption);//PreparethedataforUIsetContentView(R.layout.main);((TextView)findViewById(R.id.caption_text)).setText("Preparing the recognizer");runRecognizerSetup();}privatevoidrunRecognizerSetup(){//Recognizerinitializationisatime-consuminganditinvolvesIO,//soweexecuteitinasynctasknewAsyncTask<Void,Void,Exception>(){@OverrideprotectedExceptiondoInBackground(Void...params){try{Assetsassets=newAssets(PocketSphinxActivity.this);FileassetDir=assets.syncAssets();setupRecognizer(assetDir);}catch(IOExceptione){returne;}returnnull;}@OverrideprotectedvoidonPostExecute(Exceptionresult){if(result!=null){((TextView)findViewById(R.id.caption_text)).setText("Failed to init recognizer "+result);}else{//switchSearch("Start Recognize");((TextView)findViewById(R.id.caption_text)).setText(R.string.test_caption);recognizer.startListening(TEST_SEARCH);}}}.execute();}@OverridepublicvoidonDestroy(){super.onDestroy();if(recognizer!=null){recognizer.cancel();recognizer.shutdown();}}/***Inpartialresultwegetquickupdatesaboutcurrenthypothesis.In*keywordspottingmodewecanreacthere,inothermodesweneedtowait*forfinalresultinonResult.*/@OverridepublicvoidonPartialResult(Hypothesishypothesis){//Toast.makeText(getApplicationContext(),"partial",Toast.LENGTH_SHORT).show();if(hypothesis==null)return;Stringtext=hypothesis.getHypstr();((TextView)findViewById(R.id.result_text)).setText(text);//recognizer.cancel();//recognizer.startListening(TEST_SEARCH);}/***Thiscallbackiscalledwhenwestoptherecognizer.*/@OverridepublicvoidonResult(Hypothesishypothesis){recognizer.stop();Toast.makeText(getApplicationContext(),"res:",Toast.LENGTH_SHORT).show();((TextView)findViewById(R.id.result_text)).setText("");if(hypothesis!=null){Stringtext=hypothesis.getHypstr();makeText(getApplicationContext(),text,Toast.LENGTH_LONG).show();}}@OverridepublicvoidonBeginningOfSpeech(){Toast.makeText(getApplicationContext(),"begin",Toast.LENGTH_SHORT).show();}/***Westoprecognizerheretogetafinalresult*/@OverridepublicvoidonEndOfSpeech(){Toast.makeText(getApplicationContext(),"end",Toast.LENGTH_SHORT).show();//if(!recognizer.getSearchName().equals(KWS_SEARCH))//switchSearch(KWS_SEARCH);}privatevoidsetupRecognizer(FileassetsDir)throwsIOException{//Therecognizercanbeconfiguredtoperformmultiplesearches//ofdifferentkindandswitchbetweenthemrecognizer=SpeechRecognizerSetup.defaultSetup().setAcousticModel(newFile(assetsDir,"files")).setDictionary(newFile(assetsDir,"model.dic"))//.setRawLogDir(assetsDir)//Todisableloggingofrawaudiocommentoutthiscall(takesalotofspaceonthedevice).setBoolean("-allphone_ci",true).getRecognizer();recognizer.addListener(this);//.setKeywordThreshold(1e-45f)//Thresholdtotuneforkeyphrasetobalancebetweenfalsealarmsandmisses//.setBoolean("-allphone_ci",true)//Usecontext-independentphoneticsearch,context-dependentistooslowformobile/*FilengramModel=newFile(assetsDir,"model.lm.DMP");recognizer.addNgramSearch(TEST_SEARCH,ngramModel);*/recognizer.addGrammarSearch(TEST_SEARCH,newFile(assetsDir,"Grammar.jsgf"));}@OverridepublicvoidonError(Exceptionerror){((TextView)findViewById(R.id.caption_text)).setText(error.getMessage());}@OverridepublicvoidonTimeout(){Toast.makeText(getApplicationContext(),"timeout",Toast.LENGTH_SHORT).show();}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The grammer I used in the training was based on sentences -it's like sentence1|sentence2
There is no such thing as a grammar based on sentences. Grammars always contain words.
and is there a way that I can make the recognizer wait more before it stops taking the input from the user?
'-vad_postspeech' parameter controls that. But overall it is better to allow user to pause and continue. You should analyze partial commands and respond to them properly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no such thing as a grammar based on sentences. Grammars always contain words.
why is that? I've tried to do this in the training and it worked well -this is what my application requires-
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I tried it on android it only recognizes one or two words from the sentence like "إِنَّا أَعْطَيْنَاكَ" instead of " إِنَّا أَعْطَيْنَاكَ الكَوْثَرَ "..... and it doesn't recognizes the first word in a correct way even when the accuracy was very good while training.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can test continuous recognition with pocketsphinx_continuous first without android.
To get help on accuracy of recognition you need to provide the test audio data and the models. Make sure you have strictly followed the tutorial recommendations too, in particular the recommendation about the size of the training data.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The grammer I used in the training was based on sentences -it's like sentence1|sentence2 and so on- and it worked well when I was training the acoustic model ... but the results of the recognizer gives me words why? and is there a way that I can make the recognizer wait more before it stops taking the input from the user?
Is there more clear documentation for using pocket sphinx for android than the current one?
There is no such thing as a grammar based on sentences. Grammars always contain words.
'-vad_postspeech' parameter controls that. But overall it is better to allow user to pause and continue. You should analyze partial commands and respond to them properly.
Not sure what you tried exactly, but "based on sentences" is not the right description of the grammar. It is better to paste it instead.
Next, your problem are unlikely related to the grammar since you already tested it in training. But you do not explain them well either.
this is my grammar
When I tried it on android it only recognizes one or two words from the sentence like "إِنَّا أَعْطَيْنَاكَ" instead of " إِنَّا أَعْطَيْنَاكَ الكَوْثَرَ "..... and it doesn't recognizes the first word in a correct way even when the accuracy was very good while training.
You can test continuous recognition with pocketsphinx_continuous first without android.
To get help on accuracy of recognition you need to provide the test audio data and the models. Make sure you have strictly followed the tutorial recommendations too, in particular the recommendation about the size of the training data.
Is there anything that I did wrong? notice that this is my first attempt to use my trained accoustic model on android..