Browse Source

优化按住说话反应慢的问题

newdev_shunjiawei
fdp 1 year ago
parent
commit
63bafb265f
  1. 2
      lib/modules/agent/views/agent_view.dart
  2. 5
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/tools/SimpleAudioReceiver.kt

2
lib/modules/agent/views/agent_view.dart

@ -576,7 +576,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver {
onPointerDown: (_) {
// 设置300ms延迟防止误触
_holdTimer = Timer(
const Duration(milliseconds: 200),
const Duration(milliseconds: 100),
() {
controller.startPushToTalk();
// if (activeSpeaker == 0) {

5
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/tools/SimpleAudioReceiver.kt

@ -237,7 +237,6 @@ class SimpleAudioReceiver(private val context: Context) {
try {
// 首先设置通话音频模式
setupCommunicationAudioMode()
val supportedSampleRates = intArrayOf(16000, 8000, 11025, 22050, 44100)
val sampleRate = supportedSampleRates.firstOrNull { rate ->
val bufferSize = AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat)
@ -309,7 +308,7 @@ class SimpleAudioReceiver(private val context: Context) {
try {
isWriting.set(true)
// 首先设置通话音频模式
setupCommunicationAudioMode()
//setupCommunicationAudioMode()
// 停止录音
audioRecord?.startRecording()
@ -329,7 +328,7 @@ class SimpleAudioReceiver(private val context: Context) {
// 停止录音
audioRecord?.stop()
// 恢复音频模式
// 恢复音频模式 这里会导致关闭麦克风卡住待优化
restoreCommunicationAudioMode()
} catch (e: Exception) {

Loading…
Cancel
Save