|
|
@ -58,6 +58,9 @@ interface AgentServiceListener { |
|
|
object AgentService : CoroutineScope { |
|
|
object AgentService : CoroutineScope { |
|
|
private val TAG = "AgentService" |
|
|
private val TAG = "AgentService" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var _isInterrupt = AtomicBoolean(true) |
|
|
|
|
|
|
|
|
private var azureSpeechKey: String = "" |
|
|
private var azureSpeechKey: String = "" |
|
|
private var azureSpeechRegion: String = "" |
|
|
private var azureSpeechRegion: String = "" |
|
|
|
|
|
|
|
|
@ -359,6 +362,9 @@ object AgentService : CoroutineScope { |
|
|
sendEvent("playback_started", mapOf("status" to "playback_started")) |
|
|
sendEvent("playback_started", mapOf("status" to "playback_started")) |
|
|
// 确保气泡音已停止,避免与TTS播放重叠 |
|
|
// 确保气泡音已停止,避免与TTS播放重叠 |
|
|
audioPlayer?.stopAudio() |
|
|
audioPlayer?.stopAudio() |
|
|
|
|
|
if(_isInterrupt.get()){ |
|
|
|
|
|
BleService.closeCodec() |
|
|
|
|
|
} |
|
|
// 发送AI说话开始广播 |
|
|
// 发送AI说话开始广播 |
|
|
val intent = |
|
|
val intent = |
|
|
Intent("com.yunqiinnovation.music_service.AI_SAY_START").apply { |
|
|
Intent("com.yunqiinnovation.music_service.AI_SAY_START").apply { |
|
|
@ -382,6 +388,9 @@ object AgentService : CoroutineScope { |
|
|
setPackage(context.packageName) |
|
|
setPackage(context.packageName) |
|
|
} |
|
|
} |
|
|
context.sendBroadcast(intent) |
|
|
context.sendBroadcast(intent) |
|
|
|
|
|
if(currentRecognitionMode == "ble_wakeup"&&_isInterrupt.get()){ |
|
|
|
|
|
BleService.openEncoder() |
|
|
|
|
|
} |
|
|
if(isplaymusic){ |
|
|
if(isplaymusic){ |
|
|
isplaymusic = false |
|
|
isplaymusic = false |
|
|
Log.e(TAG, "QQ 音乐恢复播放") |
|
|
Log.e(TAG, "QQ 音乐恢复播放") |
|
|
@ -513,7 +522,17 @@ object AgentService : CoroutineScope { |
|
|
startIdleCheckForMode(currentRecognitionMode) |
|
|
startIdleCheckForMode(currentRecognitionMode) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 切换中断状态 |
|
|
|
|
|
* 如果当前为false,则设置为true;如果当前为true,则设置为false |
|
|
|
|
|
* @return 切换后的状态值 |
|
|
|
|
|
*/ |
|
|
|
|
|
fun isInterrupt(): Boolean { |
|
|
|
|
|
val currentValue = _isInterrupt.get() |
|
|
|
|
|
val newValue = !currentValue |
|
|
|
|
|
_isInterrupt.set(newValue) |
|
|
|
|
|
return newValue |
|
|
|
|
|
} |
|
|
/** |
|
|
/** |
|
|
* 开始语音识别 |
|
|
* 开始语音识别 |
|
|
* @param isExternalActive 是否使用外部音频源(蓝牙) |
|
|
* @param isExternalActive 是否使用外部音频源(蓝牙) |
|
|
@ -997,6 +1016,7 @@ object AgentService : CoroutineScope { |
|
|
override fun onComplete(sessionid: String) { |
|
|
override fun onComplete(sessionid: String) { |
|
|
try { |
|
|
try { |
|
|
if (sessionid == currsessionId) { |
|
|
if (sessionid == currsessionId) { |
|
|
|
|
|
|
|
|
audioPlayer?.stopAudio() |
|
|
audioPlayer?.stopAudio() |
|
|
} |
|
|
} |
|
|
// 视情况决定是否朗读回复 |
|
|
// 视情况决定是否朗读回复 |
|
|
|