Browse Source

add

newdev_shunjiawei
wolfplus 1 year ago
parent
commit
e8ea2b49ef
  1. 4
      android/settings.gradle.kts
  2. 21
      lib/modules/pairing/controllers/pairing_controller.dart
  3. 1
      local_plugins/agent_service/android/build.gradle.kts
  4. 24
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

4
android/settings.gradle.kts

@ -40,6 +40,7 @@ include(":classic_bluetooth")
include(":agent_service")
include(":speech")
include(":chat_api")
include(":bytedance_speech")
// 设置azure_speech项目的路径
project(":azure_speech").projectDir = file("../local_plugins/azure_speech/android")
@ -50,4 +51,5 @@ project(":ble_service").projectDir = file("../local_plugins/ble_service/android"
project(":classic_bluetooth").projectDir = file("../local_plugins/classic_bluetooth/android")
project(":agent_service").projectDir = file("../local_plugins/agent_service/android")
project(":speech").projectDir = file("../local_plugins/speech/android")
project(":chat_api").projectDir = file("../local_plugins/chat_api/android")
project(":chat_api").projectDir = file("../local_plugins/chat_api/android")
project(":bytedance_speech").projectDir = file("../local_plugins/bytedance_speech/android")

21
lib/modules/pairing/controllers/pairing_controller.dart

@ -506,7 +506,15 @@ class PairingController extends GetxController {
/// 导航到主页
void _navigateToHome() {
Future.delayed(const Duration(seconds: 1), () {
Future.delayed(const Duration(seconds: 1), () async {
// 启动AgentService服务
try {
Logger.i(_tag, '启动AgentService服务');
await _bleManager.startAgentService();
} catch (e) {
Logger.e(_tag, '启动AgentService失败: $e');
}
Get.offAllNamed(Routes.home);
});
}
@ -563,8 +571,17 @@ class PairingController extends GetxController {
}
/// 用户点击跳过按钮
void onSkipTap() {
void onSkipTap() async {
Logger.i(_tag, '用户选择跳过配对');
// 启动AgentService服务
try {
Logger.i(_tag, '启动AgentService服务');
await _bleManager.startAgentService();
} catch (e) {
Logger.e(_tag, '启动AgentService失败: $e');
}
Get.offAllNamed(Routes.home);
}

1
local_plugins/agent_service/android/build.gradle.kts

@ -50,4 +50,5 @@ dependencies {
add("compileOnly", project(":speech"))
add("compileOnly", project(":chat_api"))
add("compileOnly", project(":location_service"))
add("compileOnly", project(":bytedance_speech"))
}

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

@ -19,7 +19,7 @@ import android.media.MediaPlayer
import com.deep_voice.speech.tts.TtsEvent
import com.deep_voice.speech.tts.TtsEventListener
import com.deep_voice.speech.tts.TtsEventType
import com.yunqiinnovation.azure_speech.AzureTtsHelper
import com.deep_voice.bytedance_speech.BytedanceTTS
/**
* 代理服务事件监听接口
*/
@ -52,8 +52,8 @@ object AgentService : CoroutineScope {
// Azure服务
private var azureAsrHelper: AzureAsrHelper? = null
// 使用AzureTtsHelper作为唯一的TTS实现
private var ttsService: AzureTtsHelper? = null
// 使用BytedanceTTS作为唯一的TTS实现
private var ttsService: BytedanceTTS? = null
// ChatAPI服务 - 使用新的ChatApiService
private lateinit var chatApiService: ChatApiService
@ -216,20 +216,20 @@ object AgentService : CoroutineScope {
val ttsAppToken = config["volcanoToken"]?.toString() ?: ""
val ttsLanguage = config["ttsLanguage"]?.toString() ?: "zh-CN"
// 创建并初始化AzureTtsHelper
val azureTtsHelper = AzureTtsHelper(context)
ttsService = azureTtsHelper
// 创建并初始化BytedanceTTS
val bytedanceTts = BytedanceTTS(context)
ttsService = bytedanceTts
// 初始化Azure TTS
val success = azureTtsHelper.initialize(
ttsAppId = "", // Azure TTS不需要appId
ttsAppToken = config["azureSpeechKey"]?.toString() ?: "", // Azure需要subscription key
ttsResource = config["azureSpeechRegion"]?.toString() ?: "", // Azure需要region信息
// 初始化Bytedance TTS
val success = bytedanceTts.initialize(
ttsAppId = ttsAppId,
ttsAppToken = ttsAppToken,
ttsResource = "", // Bytedance TTS不需要resource参数
language = ttsLanguage
)
if (!success) {
Log.e(TAG, "Azure TTS服务初始化失败")
Log.e(TAG, "Bytedance TTS服务初始化失败")
}
// 添加TTS事件监听

Loading…
Cancel
Save