|
|
|
@ -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事件监听 |
|
|
|
|