Speech Recognizer on Google Wear in Emulator no voice input

蹲街弑〆低调 提交于 2019-12-13 16:56:39

问题


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);
}

}


回答1:


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




回答2:


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)



来源:https://stackoverflow.com/questions/24597164/speech-recognizer-on-google-wear-in-emulator-no-voice-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!