diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift index 6689f5138..2d08ca702 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureTtsHelper.swift @@ -276,11 +276,9 @@ public class AzureTtsHelper: NSObject, ITtsService { do { print("liwei-------------停止语音合成播放") - // 使用异步停止方法 + // 使用同步停止方法 if let synthesizer = self.synthesizer { - let stopFuture = synthesizer.stopSpeakingAsync() - // 等待停止操作完成 - _ = stopFuture.get() + try synthesizer.stopSpeaking() } self.notifyEvent(eventType: .synthesisCanceled) @@ -328,8 +326,7 @@ public class AzureTtsHelper: NSObject, ITtsService { // 确保合成器完全停止后再销毁 if let synthesizer = self.synthesizer { do { - let stopFuture = synthesizer.stopSpeakingAsync() - _ = try stopFuture.get() + try synthesizer.stopSpeaking() } catch { os_log("停止合成器失败: %{public}@", log: self.log, type: .error, error.localizedDescription) } @@ -493,28 +490,18 @@ public class AzureTtsHelper: NSObject, ITtsService { } os_log("开始合成: %{public}@", log: log, type: .debug, ssml) - // 使用异步合成方法 + // 使用同步合成方法 if let synthesizer = self.synthesizer { - let future = synthesizer.speakSsmlAsync(ssml) - - // 在后台等待合成完成 - DispatchQueue.global(qos: .userInitiated).async { [weak self] in - defer { - self?.synthesisGroup.leave() - } - - do { - let result = try future.get() - os_log("合成完成,结果: %{public}@", log: self?.log ?? OSLog.default, type: .debug, String(describing: result.reason)) - } catch { - self?.speaking = false - self?.pendingTextCount = max(0, (self?.pendingTextCount ?? 0) - text.count) - os_log("异步语音合成失败: %{public}@", log: self?.log ?? OSLog.default, type: .error, error.localizedDescription) - self?.notifyEvent(eventType: .error, params: [ - "errorCode": "ASYNC_SYNTHESIS_FAILED", - "errorMessage": error.localizedDescription - ]) - } + do { + try synthesizer.startSpeakingSsml(ssml) + os_log("合成开始成功", log: self.log, type: .debug) + } catch { + self.speaking = false + os_log("合成失败: %{public}@", log: self.log, type: .error, error.localizedDescription) + self.notifyEvent(eventType: .error, params: [ + "errorCode": "SYNTHESIS_FAILED", + "errorMessage": error.localizedDescription + ]) } } diff --git a/pubspec.yaml b/pubspec.yaml index 1a6b7388d..d8cd1e987 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: voitrans description: "Voitrans - AI Voice Assistant." publish_to: "none" -version: 1.0.14+37 +version: 1.0.15+38 environment: sdk: ">=3.3.0 <4.0.0"