我正在开发一个应用程序,我必须检测语音的响度。意味着移动设备上的一些呼喊,它将在屏幕上显示响度级别。
哪个API可以用于此?
看看http://developer.android.com/reference/android/media/AudioRecord.html
读取缓冲区时,字节值将代表幅度。字节值越高声音越大。
这是我在一段时间后写的应用中使用的缩小版本:
将其添加到manifest.xml中 qazxsw poi
soundlevel.xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
sound level.Java
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ToggleButton
android:id="@+id/togglebutton_record"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton" />
<ProgressBar
android:id="@+id/progressbar_level"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>