|
|
|
@ -741,8 +741,8 @@ object AgentService : CoroutineScope { |
|
|
|
} |
|
|
|
|
|
|
|
var text = result |
|
|
|
if(text.isNotEmpty()) |
|
|
|
{ |
|
|
|
if(text.isNotEmpty()) |
|
|
|
{ |
|
|
|
text = text.replace(Regex("^[,。?、!, . ? !]+"), "") |
|
|
|
recognitionResult += text |
|
|
|
} |
|
|
|
@ -752,45 +752,45 @@ object AgentService : CoroutineScope { |
|
|
|
} |
|
|
|
if (recognitionResult.isNotEmpty()) |
|
|
|
{ |
|
|
|
if (currentRecognitionMode == "push_to_talk") { //按住说话 |
|
|
|
sendEvent( |
|
|
|
"recognizing", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
if (currentRecognitionMode == "push_to_talk") { //按住说话 |
|
|
|
sendEvent( |
|
|
|
"recognizing", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
}else{ |
|
|
|
pendingProcessJob?.cancel() |
|
|
|
sendEvent( |
|
|
|
"recognizing", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
}else{ |
|
|
|
pendingProcessJob?.cancel() |
|
|
|
sendEvent( |
|
|
|
"recognizing", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
pendingProcessJob = launch { |
|
|
|
delay(1500) |
|
|
|
sendEvent( |
|
|
|
"recognition_result", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
pendingProcessJob = launch { |
|
|
|
delay(1500) |
|
|
|
sendEvent( |
|
|
|
"recognition_result", mapOf( |
|
|
|
"sessionid" to currsessionAsrId, |
|
|
|
"text" to recognitionResult, |
|
|
|
"language" to detectedLanguage |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
recognitionResult = "" |
|
|
|
currsessionAsrId = "" |
|
|
|
|
|
|
|
processWithChatApi(currsessionAsrId, recognitionResult) |
|
|
|
|
|
|
|
recognitionResult = "" |
|
|
|
currsessionAsrId = "" |
|
|
|
|
|
|
|
processWithChatApi(currsessionAsrId, recognitionResult) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Log.d(TAG, "liwei-------- onResult: $sessionid $result $currentRecognitionMode 空字符串") |
|
|
|
} |
|
|
|
// } |
|
|
|
else |
|
|
|
{ |
|
|
|
Log.d(TAG, "liwei-------- onResult: $sessionid $result $currentRecognitionMode 空字符串") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_hasSpeechDetected.set(false) |
|
|
|
restartIdleCheck() |
|
|
|
|