2

I was trying to use the Free-form Speech Input from Google Wear site.

From the hello world example, I just added a click on textView. It does bring up the Speak Now activity from the speech intent, but the emulator was not able to detect any sound from my mic.

I'm using Mac OS 10.9.3, I've tried both arm and intel version of the wear watch, and checked the hardware keyboard present on the AVD creation. The documentation said there is a system built-in Speech Recognizer, so installing the Google Voice app like you might do in a mobile emulator seems to be a wrong answer?

public class MainActivity extends Activity {

private TextView mTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTextView = (TextView) stub.findViewById(R.id.text);
            mTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    displaySpeechRecognizer();
                }
            });
        }
    });
}


private static final int SPEECH_REQUEST_CODE = 0;

// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

    // Start the activity, the intent will be populated with the speech text
    startActivityForResult(intent, SPEECH_REQUEST_CODE);
}

// This callback is invoked when the Speech Recognizer returns.
// This is where you process the intent and extract the speech text from the intent.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {
        List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        String spokenText = results.get(0);
        // Do something with spokenText
    }
    super.onActivityResult(requestCode, resultCode, data);
}

}

monmonja
  • 2,203
  • 5
  • 22
  • 33

3 Answers3

2

I figured out by this post Receiving voice input from an Android wearable emulator that you could use the keyboard for input, i think for now thats okay

Community
  • 1
  • 1
monmonja
  • 2,203
  • 5
  • 22
  • 33
  • You answered a few seconds before me :) Yeah, the emulator does not support voice input. You need a real device for that. – matiash Jul 06 '14 at 19:20
1

As per android documentation - The Android emulator does not support voice input. When using the emulator for a wearable device, enable Hardware keyboard present in the AVD settings so you can type replies instead (http://developer.android.com/training/wearables/notifications/voice-input.html)

ruchita
  • 163
  • 2
  • 11
0

In the Emulator: 3 dots -> Microphone -> Virtual microphone uses host audio input

Damast
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 23 '23 at 01:10