fixed a bug
This commit is contained in:
@@ -100,6 +100,7 @@ class MainActivity : Activity() {
|
||||
private var mediaRecorder: MediaRecorder? = null
|
||||
private var recordingFile: File? = null
|
||||
private val dubSegments = mutableMapOf<Int, File>()
|
||||
private val latestScores = mutableMapOf<Int, ImitationAssessmentResult>()
|
||||
private var mergedDubFile: File? = null
|
||||
private var dubbingStatusText: TextView? = null
|
||||
private var dubbingPlayback = false
|
||||
@@ -1207,6 +1208,25 @@ class MainActivity : Activity() {
|
||||
"{\"sentence_index\":$it}"
|
||||
}
|
||||
text("segments", payload)
|
||||
val scores = dubSegments.keys.sorted().map { index ->
|
||||
latestScores[index]
|
||||
}.filterNotNull().joinToString(",", "[", "]") { score ->
|
||||
buildString {
|
||||
append("{\"sentence_index\":")
|
||||
append(score.sentenceIndex)
|
||||
if (score.overallScore != null) {
|
||||
append(",\"overall_score\":")
|
||||
append(score.overallScore)
|
||||
}
|
||||
score.recognizedText?.let { text ->
|
||||
append(",\"recognized_text\":\"")
|
||||
append(text.replace("\\", "\\\\").replace("\"", "\\\""))
|
||||
append("\"")
|
||||
}
|
||||
append("}")
|
||||
}
|
||||
}
|
||||
text("scores", scores)
|
||||
dubSegments.toSortedMap().forEach { (index, file) ->
|
||||
output.writeBytes("--$boundary\r\n")
|
||||
output.writeBytes(
|
||||
@@ -1260,6 +1280,9 @@ class MainActivity : Activity() {
|
||||
if (::testStatusText.isInitialized) {
|
||||
applyAssessmentResult(result)
|
||||
}
|
||||
sentence.index.let { index ->
|
||||
latestScores[index] = result
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(error: Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user