很少說了 很簡單 只是用到了訊飛科技的東西 本身瞭解下哈app
appid是在訊飛註冊後纔有的ide
RecognizerDialog dialog;
Button button;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button) findViewById(R.id.button1);
tv=(TextView) findViewById(R.id.textView1);
dialog=new RecognizerDialog(this, "appid=523e612b");
dialog.setEngine("sms", null, null);
dialog.setListener(listener);
button.setOnClickListener(click);
}
OnClickListener click=new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.show();//danchuyuyinshibiekongjian
}
};
RecognizerDialogListener listener=new RecognizerDialogListener() {
@Override
public void onResults(ArrayList<RecognizerResult> result, boolean arg1) {
// TODO Auto-generated method stub
StringBuilder sb=new StringBuilder();
for(RecognizerResult str : result){
sb.append(str.text);
}
tv.setText(sb);
}
@Override
public void onEnd(SpeechError arg0) {
// TODO Auto-generated method stub
}
};ui