Couldn't finish up with the bluetooth part of the project. Will deal with it on a good day ( hopefully next week). Luckily, I'm gonna have 9 days OFF. Next week, TCS and HCL companies are coming to the college for Campus Selection. A lot of people get selected in that (here, every Btech student's last hope is TCS), so, we were given a week off for preparation. Anyways its not my issue. Coming back to Speech Recognition.
I used the speech recognition API provided by Android - simple, easy and perfect. Works better than what i thought. One drawback is that it uses an Internet (google) service to identify speech and convert it to words. We are planning to use Pocket-Sphinx in the future where the signal processing is done on-board but the drawback in that is that it has high RAM requirements. It takes quite some time to recognize words from speech even when I tested it on my PC (4GB RAM). Lets see about it in the future. For now, this will do.
Some of the images in my app:
As you can see above, there is a list of strings returned. Actually the intent returns an ArrayList<String>, which is added to the ListView as ArrayAdapter. I'm planning to store all the possible commands (to be sent from Android->uC) in the database and when the user gives a command through speech, we iterate through the ArrayList returned by the intent using ArrayList.Iterator() and look for a possible match in the database. It requires an efficient algorithm to search the database and find the match. Then, the matched command is sent to the uC. I believe that this idea is better than OK.
A chunk of code for iterating through the ArrayList and looking for Integers:
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- if(requestCode==check && resultCode==RESULT_OK)
- {
- ArrayList<String> results=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
- while(results.iterator().hasNext())
- {
- String temp=results.iterator().next().toString();
- if(isInteger(temp))
- {
- tvSpeechResult.setText(temp);
- break;
- }
- }
- }
- super.onActivityResult(requestCode, resultCode, data);
- }
- public boolean isInteger(String ip)
- {
- try {
- Integer.parseInt(ip);
- return true;
- } catch (Exception e) {
- return false;
- }
- }
Hoping to get back to the Bluetooth API soon...
0 comments:
Post a Comment