修复把唤醒播放提示也给录音进去的问题
This commit is contained in:
parent
2606d0144f
commit
6f65a48686
@ -85,11 +85,12 @@ class VoiceController(
|
||||
// 唤醒检测
|
||||
wakeupManager.acceptAudio(samples)
|
||||
if (wakeupManager.consumeWakeupFlag()) {
|
||||
val preBufferSnapshot = preBuffer.toFloatArray()
|
||||
handleWakeupEvent()
|
||||
// 注册唤醒用户特征
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
VoiceUtils.registerWakeupUser(
|
||||
preBuffer = preBuffer,
|
||||
preBuffer = ArrayDeque(preBufferSnapshot.asList()), // 用快照创建新队列
|
||||
extractor = speakerExtractor,
|
||||
manager = speakerManager
|
||||
)
|
||||
@ -213,6 +214,7 @@ class VoiceController(
|
||||
if (stateManager.state == VoiceState.UPLOADING) return
|
||||
stopBackendAudio?.invoke()
|
||||
stateManager.enterWakeup(interrupt = true, resetRealtimeStats = ::resetRealtimeStats)
|
||||
preBuffer.clear()
|
||||
onWakeup()
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ import com.zs.smarthuman.BuildConfig
|
||||
import com.zs.smarthuman.R
|
||||
import com.zs.smarthuman.base.BaseActivity
|
||||
import com.zs.smarthuman.base.BaseViewModelActivity
|
||||
import com.zs.smarthuman.bean.AudioDTO
|
||||
import com.zs.smarthuman.bean.NetworkStatusEventMsg
|
||||
import com.zs.smarthuman.bean.UserInfoResp
|
||||
import com.zs.smarthuman.bean.VersionUpdateResp
|
||||
@ -191,10 +190,6 @@ class MainActivity : BaseViewModelActivity<ActivityMainBinding, MainViewModel>()
|
||||
voiceController = VoiceController(
|
||||
assetManager = assets,
|
||||
onWakeup = {
|
||||
//每次唤醒前都要把前面的音频停掉
|
||||
if (backPlaying){
|
||||
mViewModel?.pauseVoice()
|
||||
}
|
||||
UnityPlayerHolder.getInstance().cancelPCM()
|
||||
UnityPlayerHolder.getInstance()
|
||||
.sendVoiceToUnity(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user