Open Source Speech Recognition Software in Java

Recently, I have been thinking about launching a speech recognition application. The value of specific results for specific tasks. I was wondering how best to move on. I also think about PC or Android. I consider JAVA to be my strong programming language.

I did a few searches, but still donโ€™t know which one works best.

Does open source software have a speech recognition part for me and work with another part? Do you do all this yourself? And if so, is this possible in JAVA?

Any information would be appreciated.

Thanks in advance.

+7
java android speech-recognition
source share
3 answers

The best way to get close to this is to use existing recognition tools and the language and acoustic models that come with it. You can train models according to your needs.

CMUSphinx is probably the best FOSS speech recognition toolkit. CMUSphinx also provides good integration with Java and demo applications.

+6
source share

After evaluating several third-party speech recognition features, Google voice recognition is by far the most accurate. When using Google Voice Recognition, there are two main approaches. The easiest way is to run Intent and process the results accordingly:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE ); 

then in your onActivityResults () you will handle the matches returned by the service:

  /** * Handle the results from the recognition activity. */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Toast.makeText(this, "voice recog result: " + resultCode, Toast.LENGTH_LONG).show(); if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) { // Fill the list view with the strings the recognizer thought it could have heard ArrayList<String> matches = data.getStringArrayListExtra( RecognizerIntent.EXTRA_RESULTS); // handleResults if (matches != null) { handleResults(matches); } } } 

The second approach is more involved, but allows you to better handle the error condition that may happen during the recognition service. Using this approach, you will create your own listening and callback methods. For example:

start listening:

 mSpeechRecognizer.startListening(mRecognizerIntent); 

where mRecognizerIntent:

  mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(getBaseContext()); mSpeechRecognizer.setRecognitionListener(mRecognitionListener); mRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); mRecognizerIntent.putExtra("calling_package", "com.you.package"); 

then create a listener:

  private RecognitionListener mRecognitionListener = new RecognitionListener() { public void onBufferReceived(byte[] buffer) { // TODO Auto-generated method stub //Log.d(TAG, "onBufferReceived"); } public void onError(int error) { // TODO Auto-generated method stub // here is where you handle the error... public void onEvent(int eventType, Bundle params) { // TODO Auto-generated method stub Log.d(TAG, "onEvent"); } public void onPartialResults(Bundle partialResults) { // TODO Auto-generated method stub Log.d(TAG, "onPartialResults"); } public void onReadyForSpeech(Bundle params) { // TODO Auto-generated method stub Log.d(TAG, "onReadyForSpeech"); } public void onResults(Bundle results) { Log.d(TAG, ">>> onResults"); //Toast.makeText(getBaseContext(), "got voice results!", Toast.LENGTH_SHORT); ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); handleResults(matches); } public void onRmsChanged(float rmsdB) { // TODO Auto-generated method stub //Log.d(TAG, "onRmsChanged"); } public void onBeginningOfSpeech() { // TODO Auto-generated method stub Log.d(TAG, "onBeginningOfSpeech"); } public void onEndOfSpeech() { // TODO Auto-generated method stub Log.d(TAG, "onEndOfSpeech"); } }; 

you can add handleResults () to do whatever you want.

+4
source share

You can also use the Google Speech API. With Android, it is available through SpeechRecognizer. Class Link

Here is a link to the stackoverflow question, which also contains demo code in Java: Speech recognition in Java

+1
source share

All Articles