缺省记录声音的机器人 [英] Default Record Voice in Android
本文介绍了缺省记录声音的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到在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.
推荐答案
有关记录的Android 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
这篇关于缺省记录声音的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文