我正在开发一款应用程序,它将记录用户的语音并将文件保存在SD卡上,然后允许用户再次听取音频。
我能够使用RecognizerIntent让用户录制自己的声音,但我无法弄清如何保存音频文件并允许用户听取音频。如果有人能帮我解决这个问题,我将不胜感激。下面是我的代码:
// Setting up the onClickListener for Audio Button
attachVoice = (Button) findViewById(R.id.AttachVoice_questionandanswer);
attachVoice.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Please Speak");
startActivityForResult(voiceIntent, VOICE_REQUEST);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == VOICE_REQUEST && resultCode == RESULT_OK){
}