|
|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.yunqiinnovation.azure_speech |
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.os.Handler |
|
|
|
import android.os.Looper |
|
|
|
import android.util.Base64 |
|
|
|
import android.util.Log |
|
|
|
import okhttp3.* |
|
|
|
@ -100,7 +102,13 @@ class XunFeiAsrHelper(private val context: Context) { |
|
|
|
try { |
|
|
|
webSocket?.let { ws: WebSocket -> |
|
|
|
ws.send("{\"end\": true, \"sessionId\": \"$sessionId\"}") |
|
|
|
ws.close(1000, "User stopped") |
|
|
|
Handler(Looper.getMainLooper()).postDelayed({ |
|
|
|
try { |
|
|
|
ws.close(1000, "User stopped") |
|
|
|
} catch (e: Exception) { |
|
|
|
Log.e(tag, "Close Xunfei failed: ${e.message}") |
|
|
|
} |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
Log.e(tag, "Stop Xunfei failed: ${e.message}") |
|
|
|
|