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