Cant start service? (Speech recog)

You have this: private void setupRecognizer(File assetDir) throws IOException { recognizer = defaultSetup() .setAcousticModel(new File(assetDir, “hmm/en-us-semi”)) .setDictionary(new File(assetDir, “lm/cmu07a.dic”)) .setKeywordThreshold(1e-5f) .getRecognizer(); recognizer.addListener(this); // recognizer.addKeywordSearch(“Hello”, assetDir); //I don’t know what this does… recognizer.startListening(“Hello”); //Start listeneing } Try changing it to this: private void setupRecognizer(File assetDir) throws IOException { recognizer = defaultSetup() .setAcousticModel(new File(assetDir, “hmm/en-us-semi”)) .setDictionary(new File(assetDir, … Read more

onServiceConnected never called after bindService method

I’ve just experienced another version of this problem, with the same symptom of onServiceConnected(…) not being called. The cause was different in my case. You must make sure to have a service declaration in your AndroidManifest.xml within the application tag – this was the root of the problem for me. <application android:name=”.YourAppTitle” android:icon=”@drawable/icon” android:label=”@string/app_name”> <activity … Read more

Streaming input to System.Speech.Recognition.SpeechRecognitionEngine

I got live speech recognition working by overriding the stream class: class SpeechStreamer : Stream { private AutoResetEvent _writeEvent; private List<byte> _buffer; private int _buffersize; private int _readposition; private int _writeposition; private bool _reset; public SpeechStreamer(int bufferSize) { _writeEvent = new AutoResetEvent(false); _buffersize = bufferSize; _buffer = new List<byte>(_buffersize); for (int i = 0; i … Read more

Android Speech Recognition Continuous Service

Class members in MainActivity private int mBindFlag; private Messenger mServiceMessenger; Start service in onCreate() @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent service = new Intent(activityContext, VoiceCommandService.class); activityContext.startService(service); mBindFlag = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ? 0 : Context.BIND_ABOVE_CLIENT; } Bind service in onStart() @Override protected void onStart() { super.onStart(); bindService(new Intent(this, VoiceCommandService.class), mServiceConnection, mBindFlag); } @Override … Read more

Is there a way to use the SpeechRecognizer API directly for speech input?

Here is the code using SpeechRecognizer class (sourced from here and here): import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.speech.RecognitionListener; import android.speech.RecognizerIntent; import android.speech.SpeechRecognizer; import android.widget.Button; import android.widget.TextView; import java.util.ArrayList; import android.util.Log; public class VoiceRecognitionTest extends Activity implements OnClickListener { private TextView mText; private SpeechRecognizer sr; private static final String TAG … Read more