Page 207 - 3-2
P. 207
public void onClick(View v) {
if (v.getId() == R.id.mic_btn) {
// intent 부분
i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
// Intent 생성
i.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
getPackageName());
// 호출한 패키지
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ko-KR");
// 인식할 언어 설정
i.putExtra(RecognizerIntent.EXTRA_PROMPT,
" 호출할 층을 말하세요");
// 유저에게 보여줄 문자
Toast.makeText(Check_Call.this, "start speak",
Toast.LENGTH_SHORT).show();
try {
startActivityForResult(i, RESULT_SPEECH);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(),
"Speech To Text 를 지원하지 않습니다.",
Toast.LENGTH_SHORT).show();
// STT 는 데이터를 필요로 함
e.getStackTrace();
}
}
}
});
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// //
output = (TextView) findViewById(R.id.want_floor);
input = (TextView) findViewById(R.id.current_floor);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (output.getText().toString().equals("1 층")) out_data = "1";
else if (output.getText().toString().equals("2 층")) out_data = "2";
else if (output.getText().toString().equals("3 층")) out_data = "3";
// 음성인식한 결과가 1 층일 경우 out_data 에는 “1” 이 저장됨.
insertToDatabase(out_data);
Log.w("Want Floor ", " " + out_data);
}
});
- 207 -