Browse Source

refactor: 优化UI间距和导航逻辑,调整语音服务初始化顺序

- 调整settings_view中的间距从50.h改为10.h
- 修改meeting_record_view的导航逻辑,添加注释说明
- 在AzureAsrToAsr中添加语音合成器语言的日志
- 清理speech_factory中的多余空行和格式
- 调整translation_controller中的初始化顺序,注释掉部分ASR初始化代码
newdev_shunjiawei
lxm 11 months ago
parent
commit
d64c8aeda1
  1. 13
      lib/data/services/speech_factory.dart
  2. 3
      lib/modules/meeting/views/meeting_record_view.dart
  3. 2
      lib/modules/settings/views/settings_view.dart
  4. 30
      lib/modules/translation/controllers/translation_controller.dart
  5. 1
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrToAsr.kt

13
lib/data/services/speech_factory.dart

@ -4,7 +4,6 @@ import 'tts_service.dart';
import 'speech_impl/azure_asr_service.dart'; import 'speech_impl/azure_asr_service.dart';
import 'speech_impl/azure_tts_service.dart'; import 'speech_impl/azure_tts_service.dart';
import '../../core/utils/logger.dart'; import '../../core/utils/logger.dart';
/// 语音服务类型 /// 语音服务类型
@ -14,7 +13,6 @@ enum SpeechServiceType {
/// Flutter 本地语音服务 /// Flutter 本地语音服务
flutter, flutter,
} }
/// 语音服务工厂类 /// 语音服务工厂类
@ -51,18 +49,13 @@ class SpeechFactory extends GetxService {
Get.delete<TtsService>(force: true); Get.delete<TtsService>(force: true);
} }
Get.lazyPut<AsrService>(() => AzureAsrService());
Get.lazyPut<AsrService>(() => AzureAsrService()); Get.lazyPut<TtsService>(() => AzureTtsService());
Get.lazyPut<TtsService>(() => AzureTtsService());
} }
/// 初始化语音服务 /// 初始化语音服务
Future<void> initialize({SpeechServiceType? initialType}) async { Future<void> initialize({SpeechServiceType? initialType}) async {
try { try {
// 注册服务 // 注册服务
_registerServices(); _registerServices();
@ -96,4 +89,4 @@ class SpeechFactory extends GetxService {
} }
return Get.find<TtsService>(); return Get.find<TtsService>();
} }
} }

3
lib/modules/meeting/views/meeting_record_view.dart

@ -422,7 +422,8 @@ class MeetingRecordView extends GetView<MeetingRecordController> {
onPressed: () async { onPressed: () async {
await controller.saveTitleChange(); await controller.saveTitleChange();
await controller.saveRecording(); await controller.saveRecording();
Get.back(); Get.back(); //关闭弹窗
Get.back(); //回退到会议记录页面
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: backgroundColor:

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

@ -46,7 +46,7 @@ class SettingsView extends GetView<SettingsController> {
_buildSystemSettingsSection(isDarkMode), _buildSystemSettingsSection(isDarkMode),
SizedBox(height: 20.h), SizedBox(height: 20.h),
_buildAboutSection(isDarkMode), _buildAboutSection(isDarkMode),
SizedBox(height: 50.h), SizedBox(height: 10.h),
], ],
), ),
bottomNavigationBar: const CommonBottomNav(currentIndex: 2), bottomNavigationBar: const CommonBottomNav(currentIndex: 2),

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

@ -372,10 +372,6 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
_timerManager = RecordTimerController(); _timerManager = RecordTimerController();
_historyManager = TranslationHistoryManager(); _historyManager = TranslationHistoryManager();
// 初始化翻译模式,根据跳转参数
final mode = Get.arguments?['translationId'] ?? 'simultaneous';
changeTranslationMode(mode);
// 初始化悬浮窗管理器 // 初始化悬浮窗管理器
_initFloatingWindowManager(); _initFloatingWindowManager();
@ -410,10 +406,22 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
// 初始化历史管理器 // 初始化历史管理器
_historyManager.initialize(); _historyManager.initialize();
// 初始化翻译模式,根据跳转参数
final mode = Get.arguments?['translationId'] ?? 'simultaneous';
changeTranslationMode(mode);
// 监听应用生命周期:当应用切到后台/失焦时兜底重置 activeSpeaker // 监听应用生命周期:当应用切到后台/失焦时兜底重置 activeSpeaker
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
} }
// @override
// void onReady() {
// super.onReady();
// // 初始化翻译模式,根据跳转参数
// final mode = Get.arguments?['translationId'] ?? 'simultaneous';
// changeTranslationMode(mode);
// }
/// 预先检查权限 /// 预先检查权限
Future<void> _preCheckPermissions() async { Future<void> _preCheckPermissions() async {
try { try {
@ -584,15 +592,15 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
sourceLanguageCode.value, sourceLanguageCode.value,
targetLanguageCode.value targetLanguageCode.value
]; ];
Logger.info('初始化ASR服务,支持语言: $asrSupportedLanguages'); Logger.info('2初始化ASR服务,支持语言: $asrSupportedLanguages');
await _asrService.initialize(supportedLanguages: asrSupportedLanguages); //await _asrService.initialize(supportedLanguages: asrSupportedLanguages);
// 获取识别事件流 // 获取识别事件流
var recognitionStream = await _asrService.recognizeCallback(); // var recognitionStream = await _asrService.recognizeCallback();
_recognitionSubscription?.cancel(); // _recognitionSubscription?.cancel();
_recognitionSubscription = // _recognitionSubscription =
recognitionStream.listen(_handleRecognitionEvent); // recognitionStream.listen(_handleRecognitionEvent);
final bool storage = await _requestStoragePermission(); final bool storage = await _requestStoragePermission();
if (!storage) { if (!storage) {
@ -618,7 +626,7 @@ class TranslationController extends GetxController with WidgetsBindingObserver {
// 初始化 ASR 服务时,明确指定需要支持的语言 // 初始化 ASR 服务时,明确指定需要支持的语言
final List<String> asrSupportedLanguages = [targetLanguageCode.value]; final List<String> asrSupportedLanguages = [targetLanguageCode.value];
Logger.info('初始化ASR服务,支持语言: $asrSupportedLanguages'); Logger.info('1初始化ASR服务,支持语言: $asrSupportedLanguages');
await _asrService.initialize(supportedLanguages: asrSupportedLanguages); await _asrService.initialize(supportedLanguages: asrSupportedLanguages);

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

@ -241,6 +241,7 @@ class IntegratedSpeechTranslationService(
SpeechConfig.fromSubscription(config.subscriptionKey, config.region).apply { SpeechConfig.fromSubscription(config.subscriptionKey, config.region).apply {
speechRecognitionLanguage = serviceConfig.sourceLanguage speechRecognitionLanguage = serviceConfig.sourceLanguage
setSpeechSynthesisVoiceName(getVoiceForLanguage(serviceConfig.targetLanguage)) setSpeechSynthesisVoiceName(getVoiceForLanguage(serviceConfig.targetLanguage))
Log.d(TAG, "设置语音合成器语言: ${serviceConfig.targetLanguage}")
setSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm) setSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm)
// 优化配置 // 优化配置

Loading…
Cancel
Save