Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Record Voice in Android

Tags:

java

android

i notice in the Android Default Voice Recorder that can sense how loud is your voice and show it to you in UI parameter .

Can i use this from the intent or how can i program a code that sense the loudness of the voice in Android.

like image 378
Jimmy Avatar asked Nov 24 '25 12:11

Jimmy


1 Answers

For recording Android android.media.MediaRecorder can be used. All API are listed in this page http://developer.android.com/reference/android/media/MediaRecorder.html. This should solve all your issues. Sample code

 MediaRecorder recorder = new MediaRecorder();
 recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
 recorder.setOutputFile(PATH_NAME);
 recorder.prepare();
 recorder.start();   // Recording is now started
 ...
 while(recordingNotOver)
 {
    int lastMaxAmplitude = recorder.getMaxAmplitude();
    // you have the value here in lastMaxAmplitude, do what u want to
 }

 recorder.stop();
 recorder.reset();   // You can reuse the object by going back to setAudioSource() step
 recorder.release(); // Now the object cannot be reused
like image 143
the100rabh Avatar answered Nov 26 '25 01:11

the100rabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!