From 2f5d3c863b79849e5e6c6be7502efc2bdadf3171 Mon Sep 17 00:00:00 2001 From: fdp <1286779656@qq.com> Date: Tue, 1 Jul 2025 21:19:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=A0=87=E9=A2=98=E5=B8=A6=E5=90=8E=E7=BC=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98+ota=E5=8D=87=E7=BA=A7=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E7=AE=80=E4=BB=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/meeting/controllers/meeting_controller.dart | 2 +- lib/modules/meeting/views/meeting_view.dart | 9 +++++++-- .../ota_upgrade/controllers/ota_upgrade_controller.dart | 4 +++- lib/modules/ota_upgrade/model/ota_upgrade_model.dart | 4 ++++ lib/modules/ota_upgrade/views/ota_upgrade_view.dart | 3 +-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/modules/meeting/controllers/meeting_controller.dart b/lib/modules/meeting/controllers/meeting_controller.dart index f7c34edbd..b9767ee74 100644 --- a/lib/modules/meeting/controllers/meeting_controller.dart +++ b/lib/modules/meeting/controllers/meeting_controller.dart @@ -36,7 +36,7 @@ class MeetingController extends GetxController { final appDocDir = getApplicationDocumentsDirectory(); List files = []; TextEditingController titleController = TextEditingController(); // 录音标题 - + String titleCSuffix = ""; // 录音标题后缀 RxList dataList = [].obs; // 蓝牙服务 final bleManager = Get.find(); diff --git a/lib/modules/meeting/views/meeting_view.dart b/lib/modules/meeting/views/meeting_view.dart index b4322b9b5..7107f8de5 100644 --- a/lib/modules/meeting/views/meeting_view.dart +++ b/lib/modules/meeting/views/meeting_view.dart @@ -559,7 +559,11 @@ class MeetingView extends GetView { 'edit'.tr, // 编辑 isDarkMode ? Colors.white : Colors.black87, () { - controller.titleController.text = data.title; + final dotIndex = data.title.lastIndexOf('.'); + controller.titleController.text = + dotIndex != -1 ? data.title.substring(0, dotIndex) : data.title; + controller.titleCSuffix = + data.title.substring(dotIndex, data.title.length); _bottomSheet(context, isDarkMode, data.id); }, ), @@ -696,7 +700,8 @@ class MeetingView extends GetView { ), GestureDetector( onTap: () { - String title = controller.titleController.text; + String title = controller.titleController.text + + controller.titleCSuffix; controller.editMeetingTitle(id, title); }, child: Container( diff --git a/lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart b/lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart index d98324272..e87191f33 100644 --- a/lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart +++ b/lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart @@ -27,6 +27,8 @@ class OtaUpgradeController extends GetxController { // 最新版本号 final RxString latestVersion = ''.obs; + // 最新更新内容 + final RxString updatedescription = ''.obs; // 当前设备固件版本号 final RxString currentVersion = ''.obs; @@ -194,7 +196,7 @@ class OtaUpgradeController extends GetxController { final resp = OtaConfigResp.fromJson(response); print('getequipmentinfo,resp.systemversion: ${resp.systemversion}'); latestVersion.value = resp.systemversion!; - + updatedescription.value = resp.updatedescription!; updatepackageaddress = resp.updatepackageaddress!; // 版本检查 diff --git a/lib/modules/ota_upgrade/model/ota_upgrade_model.dart b/lib/modules/ota_upgrade/model/ota_upgrade_model.dart index 2c35ff1ea..4e02b2b9f 100644 --- a/lib/modules/ota_upgrade/model/ota_upgrade_model.dart +++ b/lib/modules/ota_upgrade/model/ota_upgrade_model.dart @@ -16,6 +16,7 @@ class OtaConfigResp { final String? equipmentname; final String? systemversion; final String? updatepackageaddress; + final String? updatedescription; // 私有构造函数 OtaConfigResp._({ this.id, @@ -23,6 +24,7 @@ class OtaConfigResp { this.equipmentname, this.systemversion, this.updatepackageaddress, + this.updatedescription, }); factory OtaConfigResp.fromJson(Map json) { @@ -38,6 +40,7 @@ class OtaConfigResp { systemversion: (infoData?['systemversion'] as String?) ?? '', updatepackageaddress: (infoData?['updatepackageaddress'] as String?) ?? '', + updatedescription: (infoData?['updatedescription'] as String?) ?? '', ); } @@ -49,6 +52,7 @@ class OtaConfigResp { 'equipmentname': instance.equipmentname, 'systemversion': instance.systemversion, 'updatepackageaddress': instance.updatepackageaddress, + 'updatedescription': instance.updatedescription, } }; } diff --git a/lib/modules/ota_upgrade/views/ota_upgrade_view.dart b/lib/modules/ota_upgrade/views/ota_upgrade_view.dart index 1bb1629bc..8245d4096 100644 --- a/lib/modules/ota_upgrade/views/ota_upgrade_view.dart +++ b/lib/modules/ota_upgrade/views/ota_upgrade_view.dart @@ -218,7 +218,7 @@ class OtaUpgradeView extends GetView { SizedBox(height: 8), // 这里可以从controller中获取更新说明,如果有的话 Text( - '1. 优化音质表现\n2. 提升连接稳定性\n3. 修复已知问题'.tr, + controller.updatedescription.value, style: TextStyle( fontSize: 14, color: isDarkMode ? Colors.grey[300] : Colors.grey[800], @@ -333,7 +333,6 @@ class OtaUpgradeView extends GetView { return Obx(() { final progress = controller.progress.value; final type = controller.type.value; - // // 处理升级失败状态:弹出 snackbar 并显示错误提示 // if (type == OtaUpgradeController.UPGRADE_FAILED || // type == OtaUpgradeController.CONNECTION_DISCONNECTION) { From 321fd15585f0c3f933489f1011adfbd1d4c7a622 Mon Sep 17 00:00:00 2001 From: fdp <1286779656@qq.com> Date: Wed, 2 Jul 2025 16:47:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E5=AE=89=E8=A3=85=E9=BA=A6=E5=85=8B=E9=A3=8E=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/modules/settings/views/settings_view.dart | 86 +++++++++---------- .../azure_speech/AzureAsrHelper.kt | 33 +++---- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index ef7c04602..5cce91556 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -548,49 +548,49 @@ class SettingsView extends GetView { // ? Colors.white.withOpacity(0.1) // : Colors.grey[200]), // 面对面翻译测试 - _buildSimpleNavigationSetting( - title: '面对面翻译测试', - subtitle: '测试面对面翻译', - icon: Icons.bluetooth_searching, - iconBgColor: isDarkMode - ? Colors.green[900]!.withOpacity(0.3) - : Colors.green[100]!, - iconColor: - isDarkMode ? Colors.green[300]! : Colors.green[600]!, - titleColor: isDarkMode ? Colors.white : null, - subtitleColor: isDarkMode ? Colors.white70 : null, - onTap: () { - Get.toNamed(Routes.ftftranslation); - }, - isDarkMode: isDarkMode, - ), - Divider( - height: 1, - color: isDarkMode - ? Colors.white.withOpacity(0.1) - : Colors.grey[200]), - // BLE测试 - _buildSimpleNavigationSetting( - title: 'opus解码测试', - subtitle: '测试opus解码', - icon: Icons.bluetooth_searching, - iconBgColor: isDarkMode - ? Colors.green[900]!.withOpacity(0.3) - : Colors.green[100]!, - iconColor: - isDarkMode ? Colors.green[300]! : Colors.green[600]!, - titleColor: isDarkMode ? Colors.white : null, - subtitleColor: isDarkMode ? Colors.white70 : null, - onTap: () { - Get.toNamed(Routes.opusTest); - }, - isDarkMode: isDarkMode, - ), - Divider( - height: 1, - color: isDarkMode - ? Colors.white.withOpacity(0.1) - : Colors.grey[200]), + // _buildSimpleNavigationSetting( + // title: '面对面翻译测试', + // subtitle: '测试面对面翻译', + // icon: Icons.bluetooth_searching, + // iconBgColor: isDarkMode + // ? Colors.green[900]!.withOpacity(0.3) + // : Colors.green[100]!, + // iconColor: + // isDarkMode ? Colors.green[300]! : Colors.green[600]!, + // titleColor: isDarkMode ? Colors.white : null, + // subtitleColor: isDarkMode ? Colors.white70 : null, + // onTap: () { + // Get.toNamed(Routes.ftftranslation); + // }, + // isDarkMode: isDarkMode, + // ), + // Divider( + // height: 1, + // color: isDarkMode + // ? Colors.white.withOpacity(0.1) + // : Colors.grey[200]), + // // BLE测试 + // _buildSimpleNavigationSetting( + // title: 'opus解码测试', + // subtitle: '测试opus解码', + // icon: Icons.bluetooth_searching, + // iconBgColor: isDarkMode + // ? Colors.green[900]!.withOpacity(0.3) + // : Colors.green[100]!, + // iconColor: + // isDarkMode ? Colors.green[300]! : Colors.green[600]!, + // titleColor: isDarkMode ? Colors.white : null, + // subtitleColor: isDarkMode ? Colors.white70 : null, + // onTap: () { + // Get.toNamed(Routes.opusTest); + // }, + // isDarkMode: isDarkMode, + // ), + // Divider( + // height: 1, + // color: isDarkMode + // ? Colors.white.withOpacity(0.1) + // : Colors.grey[200]), // BLE测试 // _buildSimpleNavigationSetting( diff --git a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt index 46b8bfaba..40e9c1861 100644 --- a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt +++ b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt @@ -136,8 +136,6 @@ class AzureAsrHelper(private val context: Context) { audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager originalAudioMode = audioManager?.mode ?: AudioManager.MODE_NORMAL - // 5. 初始化麦克风数据 - initAudioRecord() // 保存配置 this.subscriptionKey = subscriptionKey @@ -381,6 +379,8 @@ class AzureAsrHelper(private val context: Context) { } try { + // 5. 初始化麦克风 + initAudioRecord() // 设置各种事件监听 setupEventListeners(callback) @@ -508,7 +508,7 @@ class AzureAsrHelper(private val context: Context) { // 停止音频处理 stopAudioProcessing() - // 停止录音 + // 停止录音 stopMicrophoneCapture() // 尝试强制关闭识别器 try { @@ -734,18 +734,18 @@ class AzureAsrHelper(private val context: Context) { // 获取已确定的采样率 val format = getOptimalAudioFormat() val supportedSampleRates = intArrayOf(16000, 8000, 11025, 22050, 44100) - + val channelConfig = AudioFormat.CHANNEL_IN_MONO // 单声道输入 + val audioFormat = AudioFormat.ENCODING_PCM_16BIT // 16位PCM格式 // 查找设备支持的最佳采样率 val sampleRate = supportedSampleRates.firstOrNull { rate -> val bufferSize = AudioRecord.getMinBufferSize( rate, - AudioFormat.CHANNEL_IN_MONO, - AudioFormat.ENCODING_PCM_16BIT + channelConfig, + audioFormat ) bufferSize > 0 // 返回正值表示支持 } ?: 16000 // 默认回退值 - val channelConfig = AudioFormat.CHANNEL_IN_MONO // 单声道输入 - val audioFormat = AudioFormat.ENCODING_PCM_16BIT // 16位PCM格式 + // 计算最小缓冲区大小(避免出现音频欠载) val minBufferSize = AudioRecord.getMinBufferSize( @@ -808,16 +808,17 @@ class AzureAsrHelper(private val context: Context) { while (!Thread.interrupted() && audioRecord?.recordingState == AudioRecord.RECORDSTATE_RECORDING) { - // 读取音频 - val bytesRead = audioRecord?.read(buffer, 0, buffer.size) ?: 0 - - if (!isPaused && bytesRead > 0) { - // 写入Azure流 - audioStream?.write(buffer) + if (!isPaused) { + // 读取音频 + val bytesRead = audioRecord?.read(buffer, 0, buffer.size) ?: 0 + if (bytesRead > 0) { + // 写入Azure流 + audioStream?.write(buffer) - // 保存录音 - recordfile?.saveAudioDataToWav(buffer) + // 保存录音 + recordfile?.saveAudioDataToWav(buffer) + } } } }.apply { start() }