-2
私は音声認識にGoogle APIを使用していますが、アプリがすべてのページの認識を開始したときにボタンなしで継続したいと思っています。Androidでの音声認識
これは私のコードです:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
edtUserName = (EditText) findViewById(R.id.edtUserName);
edtCode = (EditText) findViewById(R.id.edtCode);
btnLogin = (Button) findViewById(R.id.btnLogin);
tx =(TextView)findViewById(R.id.tx);
speechButton = (Button) findViewById(R.id.speechButton);
btnLogin.setOnClickListener(new View.OnClickListener(){
public void onClick (View v){
Login();
}
});
speechButton.setOnClickListener(new View.OnClickListener(){
public void onClick (View v){
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech to text");
startActivityForResult(intent, 1);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
switch (matches.get(0).toString()) {
case "prénom":
edtUserName.requestFocus();
break;
case "code":
edtCode.requestFocus();
break;
case "login":
Login();
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
}
しかし、それは連続していません –
@MarzoukAlaあなたは連続で何を意味しますか? –
私はいつも動いている音声認識サービスを意味する –