|
|
|
@ -6,6 +6,7 @@ import 'package:get_storage/get_storage.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:ble_service/ble_service.dart'; |
|
|
|
import 'package:agent_service/agent_service.dart'; |
|
|
|
import 'package:voitrans/data/models/appconfig_model.dart'; |
|
|
|
|
|
|
|
import '../../data/models/appconfig.dart'; |
|
|
|
import '../../core/utils/logger.dart'; |
|
|
|
@ -639,6 +640,35 @@ class BleManager extends GetxService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String getDeviceName() { |
|
|
|
if (deviceInfo.value != null) { |
|
|
|
return deviceInfo.value!.name; |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
// 加载TTS偏好设置 |
|
|
|
Future<bool> _loadTtsInterrupe() async { |
|
|
|
try { |
|
|
|
if (!_storage.hasData("agent_tts_interrupe")) { |
|
|
|
// 获取设备类型以确定检查策略 |
|
|
|
String deviceName = getDeviceName(); |
|
|
|
DBProduct? product = AppConfig.getproduct(deviceName); |
|
|
|
if (deviceName != "" && product != null) { |
|
|
|
// Logger.d('AgentController', |
|
|
|
// 'liwe----------product $deviceName ${product.toJson()}'); |
|
|
|
return !product.iscontinuouschat!; |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
return _storage.read('agent_tts_interrupe') ?? false; |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// 启动BLE服务 |
|
|
|
Future<bool> startAgentService() async { |
|
|
|
try { |
|
|
|
@ -668,6 +698,8 @@ class BleManager extends GetxService { |
|
|
|
// 从Flutter资源包中加载.mcp.json |
|
|
|
final jsonData = AppConfig.mcpConfig(); |
|
|
|
Logger.info('启动BLE服务,musicServiceType: ${musicServiceType}'); |
|
|
|
final isTtsInterruptEnabled = await _loadTtsInterrupe(); |
|
|
|
|
|
|
|
// 根据APP语言动态配置语音识别语言 |
|
|
|
List<String> supportedLanguages = []; |
|
|
|
try { |
|
|
|
@ -737,6 +769,7 @@ class BleManager extends GetxService { |
|
|
|
'supportedLanguages': supportedLanguages, |
|
|
|
'musicServiceType': musicServiceType, |
|
|
|
"navigationMode": navigationMode, |
|
|
|
"isttsinterrupt": isTtsInterruptEnabled ? "true" : "false", |
|
|
|
"callingTool": "callingTool".tr |
|
|
|
}; |
|
|
|
|
|
|
|
|