Browse Source

修复通话时候播报了音频

weicu
fdp 1 year ago
parent
commit
526e19d09e
  1. 15
      lib/modules/translation/controllers/translation_controller.dart
  2. 2
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleAgent.kt
  3. 2
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift
  4. 4
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt
  5. 2
      local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift
  6. 2
      local_plugins/azure_speech/ios/azure_speech/Sources/tools/MicrophoneCapture.swift
  7. 4
      local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt
  8. 2
      local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt
  9. 6
      local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift
  10. 2
      local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift
  11. 4
      local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftOpusAudioProcessor.swift
  12. 2
      local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt

15
lib/modules/translation/controllers/translation_controller.dart

@ -637,13 +637,6 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
} }
print("处理识别中事件:${event.text}"); print("处理识别中事件:${event.text}");
handleIntermediateResult(event.text); handleIntermediateResult(event.text);
} else if (event.type == RecognitionEventType.finalResult1 &&
event.text.isNotEmpty) {
if (event.detectedLanguage.isNotEmpty) {
detectedLanguageCode1.value = event.detectedLanguage;
}
latestRecognitionText.value = event.text;
print("处理麦:${event.text}");
} else if (event.type == RecognitionEventType.error) { } else if (event.type == RecognitionEventType.error) {
Get.snackbar('error'.tr, event.error); Get.snackbar('error'.tr, event.error);
isRecognizing.value = false; isRecognizing.value = false;
@ -948,11 +941,9 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
/// 处理TTS播放 /// 处理TTS播放
/// [translationResult] 翻译结果 /// [translationResult] 翻译结果
Future<void> _handleTtsPlayback(String translationResult) async { Future<void> _handleTtsPlayback(String translationResult) async {
//if (isTtsEnabled.value && currentMode.value != 'faceToFace') { if (isTtsEnabled.value) {
await playTranslatedText(translationResult); await playTranslatedText(translationResult);
// } else { }
// await _handleFaceToFaceTts(translationResult);
// }
} }
// /// 处理面对面TTS // /// 处理面对面TTS

2
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleAgent.kt

@ -135,7 +135,7 @@ Log.d(TAG, "手动启动语音识别: ")
AgentService.pushAudioData(data) AgentService.pushAudioData(data)
// 可选:处理音频数据 // 可选:处理音频数据
} }
override fun onAudioDataReceived1(data: ByteArray) { override fun onAudioDataReceivedCall(data: ByteArray) {
} }
/** /**

2
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -1510,7 +1510,7 @@ extension AgentServiceImpl: BleService.Callback {
pushAudioData(data) pushAudioData(data)
} }
func onAudioDataReceived1(data: Data) { func onAudioDataReceivedCall(data: Data) {
} }

4
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt

@ -1003,9 +1003,9 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
// 可选:处理音频数据 // 可选:处理音频数据
} }
override fun onAudioDataReceived1(data: ByteArray) { override fun onAudioDataReceivedCall(data: ByteArray) {
// FileLogger.d(tag, "onAudioDataReceived1: ${data.size}") // FileLogger.d(tag, "onAudioDataReceivedCall: ${data.size}")
azureAstHelper.pushAudioData(data) azureAstHelper.pushAudioData(data)
// 可选:处理音频数据 // 可选:处理音频数据

2
local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift

@ -947,7 +947,7 @@ extension AzureSpeechPlugin: BleService.Callback {
/// 接收到音频数据回调1 /// 接收到音频数据回调1
/// - Parameter data: 音频数据 /// - Parameter data: 音频数据
public func onAudioDataReceived1(data: Data) { public func onAudioDataReceivedCall(data: Data) {
// 安全解包版本 // 安全解包版本
guard let audioStream = azureAstHelper.audioProcessor else { guard let audioStream = azureAstHelper.audioProcessor else {
os_log("音频流未初始化", type: .error) os_log("音频流未初始化", type: .error)

2
local_plugins/azure_speech/ios/azure_speech/Sources/tools/MicrophoneCapture.swift

@ -318,7 +318,7 @@ public class MicrophoneCapture: NSObject {
// 转换成功且无错误 // 转换成功且无错误
if status == .haveData, error == nil { if status == .haveData, error == nil {
let data = strongSelf.audioBufferToData(convertedBuffer) let data = strongSelf.audioBufferToData(convertedBuffer)
print("转换后数据长度: \(data.count)") //print("转换后数据长度: \(data.count)")
strongSelf.audioDataHandler?(data) strongSelf.audioDataHandler?(data)
} }
} }

4
local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt

@ -55,7 +55,7 @@ object BleService {
// 数据相关回调 // 数据相关回调
fun onAudioDataReceived(data: ByteArray) fun onAudioDataReceived(data: ByteArray)
// 数据相关回调 // 数据相关回调
fun onAudioDataReceived1(data: ByteArray) fun onAudioDataReceivedCall(data: ByteArray)
// 唤醒信号相关回调 // 唤醒信号相关回调
fun onWakeupSignalReceived() fun onWakeupSignalReceived()
@ -1995,7 +1995,7 @@ startBytesStatistics()
private fun notifyAudioDataReceived1(data: ByteArray) { private fun notifyAudioDataReceived1(data: ByteArray) {
for (callback in callbacks) { for (callback in callbacks) {
try { try {
callback.onAudioDataReceived1(data) callback.onAudioDataReceivedCall(data)
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "分发音频数据回调异常", e) Log.e(TAG, "分发音频数据回调异常", e)
} }

2
local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt

@ -361,7 +361,7 @@ class BleServicePlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
// sendEvent(dataEventSink, mapOf("type" to "audioData", "data" to data), "发送音频数据异常") // sendEvent(dataEventSink, mapOf("type" to "audioData", "data" to data), "发送音频数据异常")
} }
override fun onAudioDataReceived1(data: ByteArray) { override fun onAudioDataReceivedCall(data: ByteArray) {
// sendEvent(dataEventSink, mapOf("type" to "audioData", "data" to data), "发送音频数据异常") // sendEvent(dataEventSink, mapOf("type" to "audioData", "data" to data), "发送音频数据异常")
} }

6
local_plugins/ble_service/ios/ble_service/Sources/ble_service/BleService.swift

@ -28,7 +28,7 @@ public class BleService: NSObject {
// 数据相关回调 // 数据相关回调
func onAudioDataReceived(data: Data) func onAudioDataReceived(data: Data)
func onAudioDataReceived1(data: Data) func onAudioDataReceivedCall(data: Data)
// 唤醒信号回调 // 唤醒信号回调
func onWakeupSignalReceived() func onWakeupSignalReceived()
@ -532,7 +532,7 @@ private var cmdReplyType: UInt8 = 0
/// 通知所有回调接收到音频数据 /// 通知所有回调接收到音频数据
private func notifyAudioDataReceived1(data: Data) { private func notifyAudioDataReceived1(data: Data) {
for callback in callbacks { for callback in callbacks {
callback.onAudioDataReceived1(data: data) callback.onAudioDataReceivedCall(data: data)
} }
} }
@ -1189,7 +1189,7 @@ extension BleService: SwiftOpusAudioProcessor.AudioDataCallback {
} }
/// 接收到解码后的PCM音频数据 /// 接收到解码后的PCM音频数据
func onAudioDataReceived1(data: Data) { func onAudioDataReceivedCall(data: Data) {
notifyAudioDataReceived1(data: data) notifyAudioDataReceived1(data: data)
} }

2
local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftBleServicePlugin.swift

@ -236,7 +236,7 @@ extension SwiftBleServicePlugin: BleService.Callback {
} }
} }
public func onAudioDataReceived1(data: Data) { public func onAudioDataReceivedCall(data: Data) {
} }

4
local_plugins/ble_service/ios/ble_service/Sources/ble_service/SwiftOpusAudioProcessor.swift

@ -9,7 +9,7 @@ class SwiftOpusAudioProcessor: NSObject {
/// 音频数据回调协议 /// 音频数据回调协议
protocol AudioDataCallback: AnyObject { protocol AudioDataCallback: AnyObject {
func onAudioDataReceived(data: Data) func onAudioDataReceived(data: Data)
func onAudioDataReceived1(data: Data) func onAudioDataReceivedCall(data: Data)
func onEncodedDataReceived(data: Data) // 编码数据回调 func onEncodedDataReceived(data: Data) // 编码数据回调
} }
@ -336,7 +336,7 @@ class SwiftOpusAudioProcessor: NSObject {
// 回调分离后的音频数据 // 回调分离后的音频数据
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.callback?.onAudioDataReceived(data: rightBuffer) self?.callback?.onAudioDataReceived(data: rightBuffer)
self?.callback?.onAudioDataReceived1(data: leftBuffer) self?.callback?.onAudioDataReceivedCall(data: leftBuffer)
} }
} }

2
local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt

@ -383,7 +383,7 @@ class OtaPlugin : BleService.Callback, FlutterPlugin, MethodCallHandler {
// 可选:处理音频数据 // 可选:处理音频数据
} }
override fun onAudioDataReceived1(data: ByteArray) { override fun onAudioDataReceivedCall(data: ByteArray) {
} }
/** /**

Loading…
Cancel
Save