|
|
@@ -259,8 +259,11 @@ public class RobotChat extends RobotBase {
|
|
|
if(EventNames.PLAYBACK_START.equalsIgnoreCase(detail)) {
|
|
|
chatRobot.setTtsChannelState(TtsChannelState.OPENED);
|
|
|
chatRobot.flushTtsRequestQueue();
|
|
|
- if (playbackStartTime <= 0) {
|
|
|
- playbackStartTime = System.currentTimeMillis();
|
|
|
+ if (ttsFirstAudioTime <= 0) {
|
|
|
+ ttsFirstAudioTime = System.currentTimeMillis();
|
|
|
+ if (playbackStartTime > 0) {
|
|
|
+ roundTtsCostMs = ttsFirstAudioTime - playbackStartTime;
|
|
|
+ }
|
|
|
}
|
|
|
long timeSpent = System.currentTimeMillis() - playbackStartTime;
|
|
|
logger.info("{} PLAYBACK_START event, time cost = {} ms. ", getTraceId(), timeSpent);
|
|
|
@@ -426,16 +429,16 @@ public class RobotChat extends RobotBase {
|
|
|
ttsChannelClosed = true;
|
|
|
recvPlayBackEndEvent = true;
|
|
|
playbackEndTime = System.currentTimeMillis();
|
|
|
- if (playbackStartTime > 0) {
|
|
|
- roundTtsCostMs = playbackEndTime - playbackStartTime;
|
|
|
- }
|
|
|
releasePlayBackFinishedSignal();
|
|
|
}
|
|
|
if("Speech-Open".equalsIgnoreCase(event)){
|
|
|
chatRobot.setTtsChannelState(TtsChannelState.OPENED);
|
|
|
chatRobot.flushTtsRequestQueue();
|
|
|
- if (playbackStartTime <= 0) {
|
|
|
- playbackStartTime = System.currentTimeMillis();
|
|
|
+ if (ttsFirstAudioTime <= 0) {
|
|
|
+ ttsFirstAudioTime = System.currentTimeMillis();
|
|
|
+ if (playbackStartTime > 0) {
|
|
|
+ roundTtsCostMs = ttsFirstAudioTime - playbackStartTime;
|
|
|
+ }
|
|
|
}
|
|
|
long timeSpent = System.currentTimeMillis() - playbackStartTime;
|
|
|
logger.info("{} Speech-Open event, time cost = {} ms. ", getTraceId(), timeSpent);
|
|
|
@@ -527,6 +530,9 @@ public class RobotChat extends RobotBase {
|
|
|
}
|
|
|
|
|
|
if ("middle".equalsIgnoreCase(speechEvent)) {
|
|
|
+ if (userSpeakStartTime <= 0) {
|
|
|
+ userSpeakStartTime = System.currentTimeMillis();
|
|
|
+ }
|
|
|
logger.info("{} ** asr-websocket, begin-speaking ** {}", getTraceId(), asrResponse);
|
|
|
logger.info("{} recv asr middle result event, recvPlayBackEndEvent={}, allowInterrupt={}, !checkSpeaking={}",
|
|
|
getTraceId(),
|
|
|
@@ -569,8 +575,8 @@ public class RobotChat extends RobotBase {
|
|
|
if (!StringUtil.isNullOrEmpty(asrResponse)) {
|
|
|
asrResultEx.add(asrResponse);
|
|
|
roundAsrText = asrResponse;
|
|
|
- if (asrWaitStartTime > 0) {
|
|
|
- roundAsrCostMs = System.currentTimeMillis() - asrWaitStartTime;
|
|
|
+ if (userSpeakStartTime > 0) {
|
|
|
+ roundAsrCostMs = System.currentTimeMillis() - userSpeakStartTime;
|
|
|
}
|
|
|
// #region debug-point xfyun-asr-no-response-asr-cache
|
|
|
logger.info("{} dbg_asr_event cached vad result, queueSize={}, response={}",
|
|
|
@@ -587,7 +593,11 @@ public class RobotChat extends RobotBase {
|
|
|
releasePlayBackFinishedSignal();
|
|
|
ThreadUtil.sleep(100);
|
|
|
} else if(chatRobot.getAccount().interruptFlag == 2 && !recvPlayBackEndEvent) {
|
|
|
- logger.info("{} interruptFlag=2 barge-in detected by vad event, interrupt current robot speech.", getTraceId());
|
|
|
+ if (isBargeInNoise(asrResponse)) {
|
|
|
+ logger.info("{} interruptFlag=2 barge-in skipped by noise filter, asrText={}", getTraceId(), asrResponse);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ logger.info("{} interruptFlag=2 barge-in detected by vad event, interrupt current robot speech. asrText={}", getTraceId(), asrResponse);
|
|
|
interruptRobotSpeech();
|
|
|
releasePlayBackFinishedSignal();
|
|
|
ThreadUtil.sleep(100);
|
|
|
@@ -704,8 +714,8 @@ public class RobotChat extends RobotBase {
|
|
|
String tmpResult = URLDecoder.decode(speechResult,"utf-8").replace(" ","");
|
|
|
asrResultEx.add(tmpResult);
|
|
|
roundAsrText = tmpResult;
|
|
|
- if (asrWaitStartTime > 0) {
|
|
|
- roundAsrCostMs = System.currentTimeMillis() - asrWaitStartTime;
|
|
|
+ if (userSpeakStartTime > 0) {
|
|
|
+ roundAsrCostMs = System.currentTimeMillis() - userSpeakStartTime;
|
|
|
}
|
|
|
logger.info("{} kaldi asr response: {}",getTraceId(), tmpResult);
|
|
|
} catch (Throwable e) {
|
|
|
@@ -845,7 +855,9 @@ public class RobotChat extends RobotBase {
|
|
|
|
|
|
// 识别开始时间
|
|
|
Long startTime = System.currentTimeMillis();
|
|
|
- playbackStartTime = 0; // will be set on Speech-Open or first TTS event
|
|
|
+ userSpeakStartTime = 0; // reset: will be set on middle/begin-speaking event
|
|
|
+ ttsFirstAudioTime = 0; // reset: will be set on Speech-Open/PLAYBACK_START
|
|
|
+ playbackStartTime = startTime; // TTS request starts from LLM call time (streaming LLM may trigger TTS during call)
|
|
|
LlmAiphoneRes aiphoneRes;
|
|
|
|
|
|
try {
|