Browse Source

Merge branch 'new_dev' of https://github.com/deepcloud2048/deep_voice into new_dev

newdev_shunjiawei
lxm 1 year ago
parent
commit
2f529c0f37
  1. 2
      lib/modules/meeting/controllers/meeting_controller.dart
  2. 9
      lib/modules/meeting/views/meeting_view.dart
  3. 4
      lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart
  4. 4
      lib/modules/ota_upgrade/model/ota_upgrade_model.dart
  5. 3
      lib/modules/ota_upgrade/views/ota_upgrade_view.dart
  6. 86
      lib/modules/settings/views/settings_view.dart
  7. 33
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt

2
lib/modules/meeting/controllers/meeting_controller.dart

@ -36,7 +36,7 @@ class MeetingController extends GetxController {
final appDocDir = getApplicationDocumentsDirectory(); final appDocDir = getApplicationDocumentsDirectory();
List<FileSystemEntity> files = []; List<FileSystemEntity> files = [];
TextEditingController titleController = TextEditingController(); // 录音标题 TextEditingController titleController = TextEditingController(); // 录音标题
String titleCSuffix = ""; // 录音标题后缀
RxList dataList = [].obs; RxList dataList = [].obs;
// 蓝牙服务 // 蓝牙服务
final bleManager = Get.find<BleManager>(); final bleManager = Get.find<BleManager>();

9
lib/modules/meeting/views/meeting_view.dart

@ -559,7 +559,11 @@ class MeetingView extends GetView<MeetingController> {
'edit'.tr, // 编辑 'edit'.tr, // 编辑
isDarkMode ? Colors.white : Colors.black87, 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); _bottomSheet(context, isDarkMode, data.id);
}, },
), ),
@ -696,7 +700,8 @@ class MeetingView extends GetView<MeetingController> {
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
String title = controller.titleController.text; String title = controller.titleController.text +
controller.titleCSuffix;
controller.editMeetingTitle(id, title); controller.editMeetingTitle(id, title);
}, },
child: Container( child: Container(

4
lib/modules/ota_upgrade/controllers/ota_upgrade_controller.dart

@ -27,6 +27,8 @@ class OtaUpgradeController extends GetxController {
// 最新版本号 // 最新版本号
final RxString latestVersion = ''.obs; final RxString latestVersion = ''.obs;
// 最新更新内容
final RxString updatedescription = ''.obs;
// 当前设备固件版本号 // 当前设备固件版本号
final RxString currentVersion = ''.obs; final RxString currentVersion = ''.obs;
@ -194,7 +196,7 @@ class OtaUpgradeController extends GetxController {
final resp = OtaConfigResp.fromJson(response); final resp = OtaConfigResp.fromJson(response);
print('getequipmentinfo,resp.systemversion: ${resp.systemversion}'); print('getequipmentinfo,resp.systemversion: ${resp.systemversion}');
latestVersion.value = resp.systemversion!; latestVersion.value = resp.systemversion!;
updatedescription.value = resp.updatedescription!;
updatepackageaddress = resp.updatepackageaddress!; updatepackageaddress = resp.updatepackageaddress!;
// 版本检查 // 版本检查

4
lib/modules/ota_upgrade/model/ota_upgrade_model.dart

@ -16,6 +16,7 @@ class OtaConfigResp {
final String? equipmentname; final String? equipmentname;
final String? systemversion; final String? systemversion;
final String? updatepackageaddress; final String? updatepackageaddress;
final String? updatedescription;
// 私有构造函数 // 私有构造函数
OtaConfigResp._({ OtaConfigResp._({
this.id, this.id,
@ -23,6 +24,7 @@ class OtaConfigResp {
this.equipmentname, this.equipmentname,
this.systemversion, this.systemversion,
this.updatepackageaddress, this.updatepackageaddress,
this.updatedescription,
}); });
factory OtaConfigResp.fromJson(Map<String, dynamic> json) { factory OtaConfigResp.fromJson(Map<String, dynamic> json) {
@ -38,6 +40,7 @@ class OtaConfigResp {
systemversion: (infoData?['systemversion'] as String?) ?? '', systemversion: (infoData?['systemversion'] as String?) ?? '',
updatepackageaddress: updatepackageaddress:
(infoData?['updatepackageaddress'] as String?) ?? '', (infoData?['updatepackageaddress'] as String?) ?? '',
updatedescription: (infoData?['updatedescription'] as String?) ?? '',
); );
} }
@ -49,6 +52,7 @@ class OtaConfigResp {
'equipmentname': instance.equipmentname, 'equipmentname': instance.equipmentname,
'systemversion': instance.systemversion, 'systemversion': instance.systemversion,
'updatepackageaddress': instance.updatepackageaddress, 'updatepackageaddress': instance.updatepackageaddress,
'updatedescription': instance.updatedescription,
} }
}; };
} }

3
lib/modules/ota_upgrade/views/ota_upgrade_view.dart

@ -218,7 +218,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
SizedBox(height: 8), SizedBox(height: 8),
// 这里可以从controller中获取更新说明,如果有的话 // 这里可以从controller中获取更新说明,如果有的话
Text( Text(
'1. 优化音质表现\n2. 提升连接稳定性\n3. 修复已知问题'.tr, controller.updatedescription.value,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: isDarkMode ? Colors.grey[300] : Colors.grey[800], color: isDarkMode ? Colors.grey[300] : Colors.grey[800],
@ -333,7 +333,6 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
return Obx(() { return Obx(() {
final progress = controller.progress.value; final progress = controller.progress.value;
final type = controller.type.value; final type = controller.type.value;
// // 处理升级失败状态:弹出 snackbar 并显示错误提示 // // 处理升级失败状态:弹出 snackbar 并显示错误提示
// if (type == OtaUpgradeController.UPGRADE_FAILED || // if (type == OtaUpgradeController.UPGRADE_FAILED ||
// type == OtaUpgradeController.CONNECTION_DISCONNECTION) { // type == OtaUpgradeController.CONNECTION_DISCONNECTION) {

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

@ -548,49 +548,49 @@ class SettingsView extends GetView<SettingsController> {
// ? Colors.white.withOpacity(0.1) // ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]), // : Colors.grey[200]),
// 面对面翻译测试 // 面对面翻译测试
_buildSimpleNavigationSetting( // _buildSimpleNavigationSetting(
title: '面对面翻译测试', // title: '面对面翻译测试',
subtitle: '测试面对面翻译', // subtitle: '测试面对面翻译',
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.ftftranslation); // Get.toNamed(Routes.ftftranslation);
}, // },
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(
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(

33
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 audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
originalAudioMode = audioManager?.mode ?: AudioManager.MODE_NORMAL originalAudioMode = audioManager?.mode ?: AudioManager.MODE_NORMAL
// 5. 初始化麦克风数据
initAudioRecord()
// 保存配置 // 保存配置
this.subscriptionKey = subscriptionKey this.subscriptionKey = subscriptionKey
@ -381,6 +379,8 @@ class AzureAsrHelper(private val context: Context) {
} }
try { try {
// 5. 初始化麦克风
initAudioRecord()
// 设置各种事件监听 // 设置各种事件监听
setupEventListeners(callback) setupEventListeners(callback)
@ -508,7 +508,7 @@ class AzureAsrHelper(private val context: Context) {
// 停止音频处理 // 停止音频处理
stopAudioProcessing() stopAudioProcessing()
// 停止录音 // 停止录音
stopMicrophoneCapture() stopMicrophoneCapture()
// 尝试强制关闭识别器 // 尝试强制关闭识别器
try { try {
@ -734,18 +734,18 @@ class AzureAsrHelper(private val context: Context) {
// 获取已确定的采样率 // 获取已确定的采样率
val format = getOptimalAudioFormat() val format = getOptimalAudioFormat()
val supportedSampleRates = intArrayOf(16000, 8000, 11025, 22050, 44100) 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 sampleRate = supportedSampleRates.firstOrNull { rate ->
val bufferSize = AudioRecord.getMinBufferSize( val bufferSize = AudioRecord.getMinBufferSize(
rate, rate,
AudioFormat.CHANNEL_IN_MONO, channelConfig,
AudioFormat.ENCODING_PCM_16BIT audioFormat
) )
bufferSize > 0 // 返回正值表示支持 bufferSize > 0 // 返回正值表示支持
} ?: 16000 // 默认回退值 } ?: 16000 // 默认回退值
val channelConfig = AudioFormat.CHANNEL_IN_MONO // 单声道输入
val audioFormat = AudioFormat.ENCODING_PCM_16BIT // 16位PCM格式
// 计算最小缓冲区大小(避免出现音频欠载) // 计算最小缓冲区大小(避免出现音频欠载)
val minBufferSize = AudioRecord.getMinBufferSize( val minBufferSize = AudioRecord.getMinBufferSize(
@ -808,16 +808,17 @@ class AzureAsrHelper(private val context: Context) {
while (!Thread.interrupted() && audioRecord?.recordingState == AudioRecord.RECORDSTATE_RECORDING) { while (!Thread.interrupted() && audioRecord?.recordingState == AudioRecord.RECORDSTATE_RECORDING) {
// 读取音频
val bytesRead = audioRecord?.read(buffer, 0, buffer.size) ?: 0
if (!isPaused && bytesRead > 0) {
// 写入Azure流 if (!isPaused) {
audioStream?.write(buffer) // 读取音频
val bytesRead = audioRecord?.read(buffer, 0, buffer.size) ?: 0
if (bytesRead > 0) {
// 写入Azure流
audioStream?.write(buffer)
// 保存录音 // 保存录音
recordfile?.saveAudioDataToWav(buffer) recordfile?.saveAudioDataToWav(buffer)
}
} }
} }
}.apply { start() } }.apply { start() }

Loading…
Cancel
Save