アプリで録音物を録音し、録音物を取得した後に音声分析を行う機能を実行しようとしています。
サウンドファイルが必要なので、MediaRecorderライブラリを使用したいと思います。これはより簡単なオプションのようです。
ただし、 http://developer.android.com/reference/android/media/MediaRecorder.htmlに基づいて録画を開始できないようです。編集:@ faz15のおかげで、クラッシュすることなくオーディオを録音できます。ただし、録音を停止できないため、サウンドクリップを取得できません。私のコードは以下の通りです:
package helloworld.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import java.io.File;
import java.io.IOException;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;
public class StartRecording extends Activity {
final AudioRecorder recorder = new AudioRecorder("/audiometer/temp");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start_recording);
//startRecording();
try {
recorder.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void stopRecording(View view) {
try {
recorder.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent(this, next_page.class);
startActivity(intent);
}
}