Browse Source

Merge commit '888839e17de279c78ef3125520d6ee8d17fdd22c' into new_dev

weicu
lxm 1 year ago
parent
commit
ce42a14a6e
  1. 44
      lib/modules/settings/views/settings_view.dart
  2. 24
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrToAsr.kt

44
lib/modules/settings/views/settings_view.dart

@ -514,28 +514,28 @@ class SettingsView extends GetView<SettingsController> {
// color: isDarkMode // color: isDarkMode
// ? Colors.white.withOpacity(0.1) // ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]), // : Colors.grey[200]),
//BLE测试 // //BLE测试
_buildSimpleNavigationSetting( // _buildSimpleNavigationSetting(
title: 'opus解码测试', // title: 'opus解码测试',
subtitle: '测试opus解码', // subtitle: '测试opus解码',
icon: Icons.bluetooth_searching, // icon: Icons.bluetooth_searching,
iconBgColor: isDarkMode // iconBgColor: isDarkMode
? Colors.green[900]!.withOpacity(0.3) // ? Colors.green[900]!.withOpacity(0.3)
: Colors.green[100]!, // : Colors.green[100]!,
iconColor: // iconColor:
isDarkMode ? Colors.green[300]! : Colors.green[600]!, // isDarkMode ? Colors.green[300]! : Colors.green[600]!,
titleColor: isDarkMode ? Colors.white : null, // titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null, // subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () { // onTap: () {
Get.toNamed(Routes.opusTest); // Get.toNamed(Routes.opusTest);
}, // },
isDarkMode: isDarkMode, // isDarkMode: isDarkMode,
), // ),
Divider( // Divider(
height: 1, // height: 1,
color: isDarkMode // color: isDarkMode
? Colors.white.withOpacity(0.1) // ? Colors.white.withOpacity(0.1)
: Colors.grey[200]), // : Colors.grey[200]),
// BLE测试 // BLE测试
// _buildSimpleNavigationSetting( // _buildSimpleNavigationSetting(

24
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrToAsr.kt

@ -1090,12 +1090,28 @@ fun getSupportedLanguages(): List<String> {
try { try {
Log.d(TAG, "开始清理服务资源") Log.d(TAG, "开始清理服务资源")
// 停止连续识别 // 停止连续识别(避免调用异步 stopContinuousTranslation 后立刻 reset 导致被取消)
if (serviceState.isRecognizing.get()) { runCatching { serviceState.isRecognizing.set(false) }
stopContinuousTranslation() try {
recognizer?.stopContinuousRecognitionAsync()
?.get(1500, java.util.concurrent.TimeUnit.MILLISECONDS)
} catch (t: Throwable) {
Log.w(TAG, "清理阶段停止识别器超时或失败", t)
} }
// 添加协程清理 // 停止录音线程(打断并短等待退出)
runCatching { audioProcessor?.stopRecording() }
.onFailure { Log.w(TAG, "清理阶段停止录音失败", it) }
// 关闭录音文件(若有)
runCatching { recordfile1?.closeFile(true) }
.onFailure { Log.w(TAG, "清理阶段关闭录音文件失败", it) }
// 清理翻译/合成状态位(不额外等待,避免阻塞主线程)
serviceState.isTranslating.set(false)
serviceState.isSynthesizing.set(false)
// 添加协程清理(放在资源停止之后,避免取消正在进行的停止协程)
resetCoroutineScope() resetCoroutineScope()
// 清理识别器 // 清理识别器

Loading…
Cancel
Save