利用headset profile实现语音采集
来源:互联网 发布:千牛淘宝直通车 编辑:程序博客网 时间:2024/05/22 06:36
一、 利用headset profile进行语音采集
在android audio系统中,已经对AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET作了规划,主要是针对headset profile实现语音输入,所以我们需要实现针对该device输入的sco HAL。即要求实现headset profile的mic输入。
1. 修改audio_policy.conf,添加遥控器mic设备以及对应的HAL;HAL命名为audio.sco.vendor.so
#bluetoothmic for headset
sco{ // HAL的名字
inputs {
mvs {
sampling_rates 16000
channel_masks AUDIO_CHANNEL_IN_MONO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET
}
}
}
2. 音频策略的修改,由于android 原生音频策略已经规划了AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,所以不用修改音频策略。
二、headsetprofile建立音频通路的过程
1. headset profile建立连接的过程
2. 建立语音通路的过程
建立语音通路的前提是headset device已经建立连接,并进入connected状态。AudioManager里建立sco连接的api:
/**
*Start bluetooth SCO audio connection.
*<p>Requires Permission:
* {@linkandroid.Manifest.permission#MODIFY_AUDIO_SETTINGS}.
*<p>This method can be used by applications wanting to send and receivedaudio
*to/from a bluetooth SCO headset while the phone is not in call.
*<p>As the SCO connection establishment can take several seconds,
*applications should not rely on the connection to be available when the method
*returns but instead register to receive the intent {@link#ACTION_SCO_AUDIO_STATE_UPDATED}
*and wait for the state to be {@link #SCO_AUDIO_STATE_CONNECTED}.
*<p>As the ACTION_SCO_AUDIO_STATE_UPDATED intent is sticky, theapplication can check the SCO
*audio state before calling startBluetoothSco() by reading the intent returnedby the receiver
*registration. If the state is already CONNECTED, no state change will bereceived via the
*intent after calling startBluetoothSco(). It is however useful to callstartBluetoothSco()
*so that the connection stays active in case the current initiator stops theconnection.
*<p>Unless the connection is already active as described above, the statewill always
*transition from DISCONNECTED to CONNECTING and then either to CONNECTED if theconnection
*succeeds or back to DISCONNECTED if the connection fails (e.g no headset isconnected).
*<p>When finished with the SCO connection or if the establishment fails,the application must
*call {@link #stopBluetoothSco()} to clear the request and turn down thebluetooth connection.
*<p>Even if a SCO connection is established, the following restrictionsapply on audio
* output streams so that they can be routed to SCO headset:
* <ul>
* <li> the stream typemust be {@link #STREAM_VOICE_CALL} </li>
* <li> the format must bemono </li>
* <li> the sampling mustbe 16kHz or 8kHz </li>
*</ul>
* <p>The following restrictions apply on input streams:
* <ul>
* <li> the format must bemono </li>
* <li> the sampling mustbe 8kHz </li>
* </ul>
*<p>Note that the phone application always has the priority on the usageof the SCO
*connection for telephony. If this method is called while the phone is in call
*it will be ignored. Similarly, if a call is received or sent while anapplication
*is using the SCO connection, the connection will be lost for the applicationand NOT
*returned automatically when the call ends.
*<p>NOTE: up to and including API version
*{@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, this method initiates avirtual
*voice call to the bluetooth headset.
*After API version {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} only a raw SCO audio
*connection is established.
*@see #stopBluetoothSco()
*@see #ACTION_SCO_AUDIO_STATE_UPDATED
*/
public void startBluetoothSco(){
IAudioService service = getService();
try {
service.startBluetoothSco(mICallBack,
getContext().getApplicationInfo().targetSdkVersion);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
3. 使用AudioRecord捕获原始音频流,我们可以对采集的数据进行降噪合成等处理,这刚好符合语音识别的语音采集要求。AudioRecord采集流程很简单,我们只需要构造一个AudioRecord对象,然后传入各种不同配置的参数即可。
- 利用headset profile实现语音采集
- Headset Profile (HSP)
- MTK Headset 实现音乐按键功能
- Headset驱动的设计与实现
- MTK Headset 实现音乐按键功能
- 【android开发】实现语音数据实时采集/播放
- 【android开发】实现语音数据实时采集/播放
- 利用NUANCE 语音识别引擎RCEngine实现语音识别
- 利用NUANCE 语音识别引擎RCEngine实现语音识别
- C# 利用socket实现语音网络通信
- 利用PISDK实现SCADA数据快速采集
- 语音传输 音频采集
- Android蓝牙连接蓝牙音箱和耳机的 A2dp与Headset Profile
- 语音信号采集和播放
- 数字化语音采集回放系统
- 【转载】VC中实现语音(声音)数据的采集(附源代码)
- VC中实现语音(声音)数据的采集(附源代码)
- 【VS开发】【智能语音处理】VS中声音的采集实现
- 手机端页面自适应解决方案—rem布局进阶版(附源码示例)
- Java中的深拷贝与浅拷贝
- UVA 1339
- VS2015 没有打包工具
- Servlet运行原理
- 利用headset profile实现语音采集
- 深入理解JVM—JVM内存模型
- C++ 开发学习笔记:C++ 数据互相转换
- 排序(二)插入排序、插入改进——二分插入排序、插入改进——希尔排序
- 输出任意实数PrintDigit
- 腾讯云Centos6.6搭建javaweb环境:mysql5.1+jdk1.7+tomcat6完整过程
- CentOS Mysql远程连接
- sqlserver2008 创建 sqlserver2008 dblink链接
- vue.js中created方法作用