Browse Source

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

weicu
liwei1dao 10 months ago
parent
commit
86a92a83f6
  1. 42
      lib/data/services/version_update_service.dart
  2. 5
      lib/modules/settings/views/settings_view.dart
  3. 20
      lib/modules/translation/middleware/controllers/translation_middleware_controller.dart
  4. 14
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt
  5. 8
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift
  6. 1
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt
  7. 6
      local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/XunFeiAsrHelper.swift
  8. 2
      pubspec.yaml

42
lib/data/services/version_update_service.dart

@ -147,14 +147,14 @@ class VersionUpdateService extends GetxService {
final brandChannel = platformInfo.channel;
// 环境变量渠道用于游客登录配置
final envChannelName = dotenv.env['Channel'] ?? 'OFFICIAL';
final envChannel = UserChannel.fromName(envChannelName);
// final envChannelName = dotenv.env['Channel'] ?? 'OFFICIAL';
final envChannel = _channel;
final AppInfo? envAppInfo = appIndex[envChannel];
// 若不存在品牌渠道信息,降级为环境渠道;仍不存在则返回无更新
final AppInfo? chosenAppInfo =
_getChannelAppInfo(appIndex, brandChannel, envChannel);
if (chosenAppInfo == null) {
final AppInfo? brandAppInfo = appIndex[brandChannel] ?? envAppInfo;
if (brandAppInfo == null) {
_logger.w('lxm--未找到品牌或环境渠道的应用信息,返回无更新');
return VersionUpdateInfo(
hasUpdate: false,
@ -164,14 +164,14 @@ class VersionUpdateService extends GetxService {
);
}
_appInfo = chosenAppInfo;
_latestVersion = chosenAppInfo.version;
_updateUrl = chosenAppInfo.address;
_appInfo = brandAppInfo;
_latestVersion = brandAppInfo.version;
_updateUrl = brandAppInfo.address;
// 设置游客登录显示状态(先用当前渠道结果作为回退,再用.env渠道覆盖以保持一致)
_isShowTourists = (envAppInfo ?? chosenAppInfo).tourists;
_isShowTourists = (envAppInfo ?? brandAppInfo).tourists;
_allowSkipDeviceBinding =
(envAppInfo ?? chosenAppInfo).allowskipdevicebinding;
(envAppInfo ?? brandAppInfo).allowskipdevicebinding;
_logger.d('lxm--从服务器获取游客登录配置(最终): ${_isShowTourists}');
@ -186,21 +186,21 @@ class VersionUpdateService extends GetxService {
// }
// final appInfo = channelAppResponse.data!.app;
_hasUpdate = _compareVersions(currentVersion, chosenAppInfo.version);
_hasUpdate = _compareVersions(currentVersion, brandAppInfo.version);
// 判断更新类型:如果主版本号不同则强制更新
UpdateType updateType = UpdateType.none;
if (_hasUpdate!) {
_isForceUpdate =
_shouldForceUpdate(currentVersion, chosenAppInfo.version);
_shouldForceUpdate(currentVersion, brandAppInfo.version);
updateType = _isForceUpdate! ? UpdateType.force : UpdateType.optional;
}
//[3]返回版本更新信息
return VersionUpdateInfo(
hasUpdate: _hasUpdate!,
currentVersion: currentVersion.split('+')[0],
latestVersion: chosenAppInfo.version.split('+')[0],
appInfo: chosenAppInfo,
latestVersion: brandAppInfo.version.split('+')[0],
appInfo: brandAppInfo,
updateType: updateType,
);
} catch (e) {
@ -427,20 +427,6 @@ class VersionUpdateService extends GetxService {
return index;
}
/// 获取渠道信息,带备选策略
///
/// 优先返回主渠道的信息,如果主渠道不存在则返回备选渠道的信息。
/// 主要用于:
/// 1. 版本更新:优先使用设备品牌渠道,备选使用环境变量渠道
/// 2. 功能配置:优先使用环境变量渠道,备选使用版本更新渠道
AppInfo? _getChannelAppInfo(
Map<UserChannel, AppInfo> index,
UserChannel primary,
UserChannel? fallback,
) {
return index[primary] ?? (fallback != null ? index[fallback] : null);
}
/// 解析版本号字符串为数字数组
List<int> _parseVersion(String version) {
final parts = version.split('.');

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

@ -761,6 +761,11 @@ class SettingsView extends GetView<SettingsController> {
onTap: () => Get.toNamed(Routes.wakeupvoice),
isDarkMode: isDarkMode,
),
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[200]),
_buildSimpleNavigationSetting(
title: 'firmwareUpgrade'.tr, // 固件升级
subtitle: 'bleHeadsetFirmwareUpgrade'.tr, // BLE耳机固件版本升级

20
lib/modules/translation/middleware/controllers/translation_middleware_controller.dart

@ -75,16 +75,16 @@ class TranslationMiddlewareController extends GetxController {
iconColor: Colors.indigo[500]!, // 主靛
targetRoute: Routes.textTranslation,
),
TranslationOption(
translationId: 'voice_replication',
title: '声音复刻',
icon: Icons.volume_up,
startColor: Colors.pink[400]!, // 粉色
endColor: Colors.pink[600]!, // 深粉
iconBgColor: Colors.white, // 白色
iconColor: Colors.pink[500]!, // 主粉
targetRoute: Routes.voiceReplication,
),
// TranslationOption(
// translationId: 'voice_replication',
// title: '声音复刻',
// icon: Icons.volume_up,
// startColor: Colors.pink[400]!, // 粉色
// endColor: Colors.pink[600]!, // 深粉
// iconBgColor: Colors.white, // 白色
// iconColor: Colors.pink[500]!, // 主粉
// targetRoute: Routes.voiceReplication,
// ),
];
/// 导航到指定的翻译功能

14
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

@ -720,13 +720,17 @@ object AgentService : CoroutineScope {
}
override fun onResult(sessionid:String,result: String, detectedLanguage: String) {
Log.d(TAG, "liwei-------- onResult: $sessionid ")
Log.d(TAG, "liwei-------- onResult: $sessionid $result $currentRecognitionMode")
if (result.isNotEmpty()&&isKeepResult==true) {//加入是否结束要输出最后的结果判读
// 保存识别结果
if (currsessionAsrId.isEmpty()) {
currsessionAsrId = sessionid
}
recognitionResult += result
var text = result
if(recognitionResult.isEmpty()) {
text = text.replace(Regex("^[,。?、!, . ? !]+"), "")
}
recognitionResult += text
if (currentRecognitionMode == "push_to_talk") { //按住说话
sendEvent(
"recognizing", mapOf(
@ -780,7 +784,7 @@ object AgentService : CoroutineScope {
override fun onSessionStopped(sessionid:String) {
Log.d(TAG, "liwei-------- onSessionStopped: $sessionid")
Log.d(TAG, "liwei-------- onSessionStopped: $sessionid $currsessionAsrId $recognitionResult $currentRecognitionMode")
if (currentRecognitionMode == "push_to_talk") { //按住说话
if (recognitionResult.isNotEmpty()){
sendEvent(
@ -855,14 +859,14 @@ object AgentService : CoroutineScope {
azureAsrHelper?.stopContinuousRecognition()
stopIdleCheck()
// 重置识别模式
currentRecognitionMode = "normal"
// currentRecognitionMode = "normal"
return
} catch (e: Exception) {
Log.e(TAG, "停止语音识别异常: ${e.message}")
_isRecognitionActive.set(false)
stopIdleCheck()
// 重置识别模式
currentRecognitionMode = "normal"
// currentRecognitionMode = "normal"
return
}
}

8
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -548,7 +548,7 @@ class AgentServiceImpl: NSObject {
}
// 重置识别模式
currentRecognitionMode = "normal"
// currentRecognitionMode = "normal"
// 启动中但已请求停止,也视为已接受停止请求
return success || isStartingRecognition
@ -2190,7 +2190,11 @@ extension AgentServiceImpl: AzureAsrHelper.ContinuousRecognizeCallback {
if currsessionAsrId.isEmpty {
currsessionAsrId = sessionid
}
recognitionResult += text
var processedText = text
if recognitionResult.isEmpty {
processedText = processedText.replacingOccurrences(of: "^[,。?、!, . ? !]+", with: "", options: .regularExpression)
}
recognitionResult += processedText
if (currentRecognitionMode == "push_to_talk") { //按住说话
var data: [String: Any] = [
"sessionid": currsessionAsrId,

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

@ -187,6 +187,7 @@ class XunFeiAsrHelper(private val context: Context) {
}
if (ls && wordCount == 0 && punctuationCount == 1) {
callback.onSessionStopped(currentSessionId)
return
}

6
local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/XunFeiAsrHelper.swift

@ -66,7 +66,10 @@ class XunFeiAsrHelper: NSObject, URLSessionWebSocketDelegate {
let endJson = "{\"end\": true, \"sessionId\": \"\(sessionId)\"}"
let message = URLSessionWebSocketTask.Message.string(endJson)
webSocketTask.send(message) { _ in }
webSocketTask.cancel(with: .normalClosure, reason: "User stopped".data(using: .utf8))
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
webSocketTask.cancel(with: .normalClosure, reason: "User stopped".data(using: .utf8))
}
}
webSocketTask = nil
}
@ -220,6 +223,7 @@ class XunFeiAsrHelper: NSObject, URLSessionWebSocketDelegate {
}
if ls && wordCount == 0 && punctuationCount == 1 {
callback?.onSessionStopped(sessionid: currentSessionId)
return
}

2
pubspec.yaml

@ -1,7 +1,7 @@
name: voitrans
description: "Voitrans - AI Voice Assistant."
publish_to: "none"
version: 1.0.20+67
version: 1.0.21+71
environment:
sdk: ">=3.3.0 <4.0.0"

Loading…
Cancel
Save