语音转换成文本
不多说了 很简单 只是用到了讯飞科技的东西 自己了解下哈
appid是在讯飞注册后才有的
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
}
};