Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 先附上程式碼
- private OnClickListener Speech2Text = new OnClickListener() {
- public void onClick(View v) {
- // 啟動語音辨識
- Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
- intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LA
- intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "請說...");
- startActivityForResult(intent, 1);
- }
- };
- .
- 略
- .
- List<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
- Log.d(TAG, "result size = "+result.size());
- int maxresult = result.size();
- tv = (TextView) this.findViewById(R.id.editText1);
- tv.setText(result.toString());
- for(int x=0;x<maxresult;x++){
- String Get = result.get(x);
- String Comparison = new String("電話");
- flat = Get.compareTo(Comparison);
- if(flat == 0){
- Intent intent2 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
- intent2.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
- intent2.putExtra(RecognizerIntent.EXTRA_PROMPT, "請選擇電話組別...");
- startActivityForResult(intent2, 1);
- List<String> result2 = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
- int maxresult_2 = result2.size();
- for(x=0;x<maxresult_2;x++){
- String Get_2 = result2.get(x);
- String P_Comparison = new String("第一");
- Log.d(TAG, "The P_Comparison String = " + P_Comparison);
- Log.d(TAG, "The result2 String = " + Get_2);
- Log.d(TAG, "開始電話比對動作…");
- flat2 = Get_2.compareTo(P_Comparison);
- if(flat2 == 0){
- Intent it = new Intent();
- it.setClass(MainActivity.this, contours.class);
- bundle=new Bundle();
- bundle.putString("myval_1", ptv1.getText().toString());
- it.putExtras(bundle);
- startActivityForResult(it, 0);
- }else Log.d(TAG, "辨識失敗...");
- }
- }else Log.d(TAG, "Get不等於電話");
- .
- 略
- .
Advertisement
Add Comment
Please, Sign In to add comment