From e840e25d4cc2821b0369e466f4c155886fca985e Mon Sep 17 00:00:00 2001 From: tanlongsheng <252620078@qq.com> Date: Tue, 9 Dec 2025 19:54:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=AF=E9=A3=9E=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt index a7786bad2..491c3dbaf 100644 --- a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt +++ b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/XunFeiAsrHelper.kt @@ -25,6 +25,7 @@ class XunFeiAsrHelper(private val context: Context) { private var currentSessionId = "" private var sessionId = "" + private var lastIntermediateResult = "" fun start(callback: AzureAsrHelper.ContinuousRecognizeCallback) { try { @@ -35,6 +36,7 @@ class XunFeiAsrHelper(private val context: Context) { } currentSessionId = UUID.randomUUID().toString() + lastIntermediateResult = "" val url = getWebSocketUrl() val request = Request.Builder().url(url).build() @@ -56,6 +58,10 @@ class XunFeiAsrHelper(private val context: Context) { override fun onClosed(webSocket: WebSocket, code: Int, reason: String) { Log.d(tag, "WebSocket Closed: $code / $reason") + if (currentSessionId.isNotEmpty() && lastIntermediateResult.isNotEmpty()) { + callback.onResult(currentSessionId, lastIntermediateResult, "zh-CN") + currentSessionId = "" + } callback.onSessionStopped(currentSessionId) } @@ -141,11 +147,13 @@ class XunFeiAsrHelper(private val context: Context) { if (st.optInt("type") == 0) { callback.onResult(currentSessionId, resultTextTemp, "zh-CN") currentSessionId = "" + lastIntermediateResult = "" } else { if (currentSessionId.isEmpty()) { currentSessionId = UUID.randomUUID().toString() callback.onSessionStarted(currentSessionId) } + lastIntermediateResult = resultTextTemp callback.onRecognizing(currentSessionId, resultTextTemp, "zh-CN") } }