缺省记录声音的机器人机器人、声音

2023-09-04 12:13:11 作者:不期待重来

我注意到在Android默认的语音记录器,可以感知的音量是你的声音和的显示它给你的UI参数。

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

我可以使用这起故意或者我怎么可以设定一个code表示感觉到Android的声音的响度。

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

推荐答案

有关记录的Andr​​oid android.media.MediaRecorder都可以使用。所有的API都列在这个网页。 http://developer.android.com/reference/安卓/媒体/ MediaRecorder.html 。这应该可以解决所有的问题。 样品code

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
 
精彩推荐
图片推荐