|
|
|
@ -107,11 +107,14 @@ class XunFeiAsrHelper(private val context: Context) { |
|
|
|
val dataStr = jsonData.optString("data") |
|
|
|
val data = JSONObject(dataStr) |
|
|
|
|
|
|
|
val ls = data.optBoolean("ls") |
|
|
|
val cn = data.optJSONObject("cn") ?: return |
|
|
|
val st = cn.optJSONObject("st") ?: return |
|
|
|
val rt = st.optJSONArray("rt") ?: return |
|
|
|
|
|
|
|
var resultTextTemp = "" |
|
|
|
var punctuationCount = 0 |
|
|
|
var wordCount = 0 |
|
|
|
|
|
|
|
for (i in 0 until rt.length()) { |
|
|
|
val j = rt.getJSONObject(i) |
|
|
|
@ -122,13 +125,27 @@ class XunFeiAsrHelper(private val context: Context) { |
|
|
|
for (l in 0 until cw.length()) { |
|
|
|
val lObj = cw.getJSONObject(l) |
|
|
|
resultTextTemp += lObj.optString("w") |
|
|
|
if (lObj.optString("wp") == "p") { |
|
|
|
punctuationCount++ |
|
|
|
} else { |
|
|
|
wordCount++ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ls && wordCount == 0 && punctuationCount == 1) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (st.optInt("type") == 0) { |
|
|
|
callback.onResult(currentSessionId, resultTextTemp, "zh-CN") |
|
|
|
currentSessionId = "" |
|
|
|
} else { |
|
|
|
if (currentSessionId.isEmpty()) { |
|
|
|
currentSessionId = UUID.randomUUID().toString() |
|
|
|
callback.onSessionStarted(currentSessionId) |
|
|
|
} |
|
|
|
callback.onRecognizing(currentSessionId, resultTextTemp, "zh-CN") |
|
|
|
} |
|
|
|
} |
|
|
|
|