我是靠谱客的博主 温柔黑裤,最近开发中收集的这篇文章主要介绍[RK3399][Android7.1] 调试笔记 --- 兼容思必驰语音识别模块到系统中,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83
需求:
使用思必驰的方案做语音识别功能,并且不影响普通的麦克风录音功能。
分析:
由于speech也是用的内置mic设备(软件中),这样和会系统使用的录音设备冲突,导致audio policy中的input profile只有一个有效。 因此两种方法解决此问题:
1.修改speech使用的设备
2.修改系统自身使用的设备
这里使用后者,相对来说方便并且可控一些。
解决方法:
Framework改动:
kris@eco:~/rk3399/frameworks/av$ g df
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index a091512..abff1b7 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -605,7 +605,11 @@ audio_devices_t Engine::getDeviceForInputSource(audio_source_t inputSource) cons
device = AUDIO_DEVICE_IN_WIRED_HEADSET;
} else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
device = AUDIO_DEVICE_IN_USB_DEVICE;
-
} else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
+
//Kris,
190116, merge Speech module into audio framework. {
+
}
else if (availableDeviceTypes & AUDIO_DEVICE_IN_BACK_MIC) {
+
device = AUDIO_DEVICE_IN_BACK_MIC;
+
//Kris,
190116, merge Speech module into audio framework. }
+
}
else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
device = AUDIO_DEVICE_IN_BUILTIN_MIC;
}
break;
HAL层改动:
kris@eco:~/rk3399/hardware/rockchip/audio$ g df 0fbb25860bb656abc420f06b902255d749ba0952 a0a3a771928a973b03d9ef6adc3e7d7685264448
diff --git a/tinyalsa_hal/audio_hw.c b/tinyalsa_hal/audio_hw.c
index e1fb819..c7c244d 100755
--- a/tinyalsa_hal/audio_hw.c
+++ b/tinyalsa_hal/audio_hw.c
@@ -338,7 +338,13 @@ uint32_t getInputRouteFromDevice(uint32_t device)
}*/
ALOGE("%s:device:%x",__FUNCTION__,device);
switch (device) {
+//Kris,
190116, merge Speech module into audio framework. {
+#if 0
case AUDIO_DEVICE_IN_BUILTIN_MIC:
+#else
+
case AUDIO_DEVICE_IN_BACK_MIC:
+#endif
+//Kris,
190116, merge Speech module into audio framework. }
return MAIN_MIC_CAPTURE_ROUTE;
case AUDIO_DEVICE_IN_WIRED_HEADSET:
return HANDS_FREE_MIC_CAPTURE_ROUTE;
添加speech库:
kris@eco:~/rk3399/device/rockchip/rk3399$ g df
diff --git a/device.mk b/device.mk
index 5d8ced7..5dd0ffd 100644
--- a/device.mk
+++ b/device.mk
@@ -303,6 +303,12 @@ PRODUCT_COPY_FILES +=
device/rockchip/rk3399/ril/lib/libreference-ril.so:system/lib/libreference-ril.so
device/rockchip/rk3399/ril/lib64/libreference-ril.so:system/lib64/libreference-ril.so
+#Kris,
190116, merge Speech module into audio framework.
+PRODUCT_COPY_FILES +=
+
device/rockchip/rk3399/aispeech/etc/aispeech_rk3399_ecovacs.bin:system/etc/aispeech_rk3399_ecovacs.bin
+
device/rockchip/rk3399/aispeech/etc/AEC_ch8-2-ch6_2ref.bin:system/etc/AEC_ch8-2-ch6_2ref.bin
+
device/rockchip/rk3399/aispeech/lib/arm/audio.aispeech.default.so:system/lib/hw/audio.aispeech.default.so
+
device/rockchip/rk3399/aispeech/lib/arm64/audio.aispeech.default.so:system/lib64/hw/audio.aispeech.default.so
audio policy文件改动:
kris@eco:~/rk3399/device/rockchip/common$ g df
diff --git a/audio_policy_rk30board.conf b/audio_policy_rk30board.conf
index 84315ad..a095d7b 100755
--- a/audio_policy_rk30board.conf
+++ b/audio_policy_rk30board.conf
@@ -5,7 +5,7 @@
global_configuration {
attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
default_output_device AUDIO_DEVICE_OUT_SPEAKER
-
attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX
+
attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_BACK_MIC
}
# audio hardware module section: contains descriptors for all audio hw modules present on the
@@ -50,7 +50,17 @@ audio_hw_modules {
sampling_rates 8000|11025|16000|22050|32000|44100|48000
channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
-
devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_WIRED_HEADSET
+
devices AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_WIRED_HEADSET
+
}
+
}
+
}
+
aispeech {
+
inputs {
+
aispeech {
+
sampling_rates 8000|16000|32000|44100|48000|128000
+
channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
+
formats AUDIO_FORMAT_PCM_16_BIT
+
devices AUDIO_DEVICE_IN_BUILTIN_MIC
}
}
}
最后
以上就是温柔黑裤为你收集整理的[RK3399][Android7.1] 调试笔记 --- 兼容思必驰语音识别模块到系统中的全部内容,希望文章能够帮你解决[RK3399][Android7.1] 调试笔记 --- 兼容思必驰语音识别模块到系统中所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复