diff --git a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift index b5abb3e9f..4755617ff 100644 --- a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift +++ b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift @@ -100,7 +100,7 @@ class AgentServiceImpl: NSObject { private let timerQueue = DispatchQueue(label: "com.example.idleTimer.queue") private var idleTimer: DispatchSourceTimer? - private let maxIdleSeconds: TimeInterval = 10 + private let maxIdleSeconds: TimeInterval = 5 var micCapture: MicrophoneCapture! // 语音识别模式 public var currentRecognitionMode: String = "normal" @@ -311,6 +311,9 @@ class AgentServiceImpl: NSObject { LocationService.shared.getCurrentLocation() { location in // self.locationInfo = location } + + checkAdnSetAudioSession() + return isInitialized } @@ -387,6 +390,11 @@ class AgentServiceImpl: NSObject { return true } + private func checkAdnSetAudioSession() { + let audioSourceType: AzureAsrHelper.AudioSourceType = BleService.shared.isConnected() ? .external : .microphone + azureAsrHelper?.performAudioStart(audioSourceType: audioSourceType, audioDataCallback: nil) + } + private func startIdleCheckForMode(mode: String) { stopIdleCheck() guard isRecognizing else { return } diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift index 9658a20af..3ea1fb6a0 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift @@ -338,7 +338,7 @@ public class AzureAsrHelper: NSObject { /** * 执行音频启动操作 */ - private func performAudioStart( + public func performAudioStart( audioSourceType: AudioSourceType, audioDataCallback: SimpleAudioReceiver.AudioDataCallback? ) -> Bool { diff --git a/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift b/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift index c13217297..0eb558514 100644 --- a/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift +++ b/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift @@ -41,10 +41,10 @@ public class MusicService: NSObject { private override init() { super.init() setupRemoteCommandCenter() - setupAudioSession() + // setupAudioSession() setupNotificationObservers() // 监听通话状态(需主线程队列) -// callObserver.setDelegate(self, queue: DispatchQueue.main) + //callObserver.setDelegate(self, queue: DispatchQueue.main) } public func initialize(serviceUrl: String, userToken: String) {