debug: show raw indices and fix boundary check
Build and Deploy / build (push) Successful in 2m43s
Build and Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-07-17 12:26:31 +00:00
parent ae4bf8dd36
commit 65c77452c2
+8 -3
View File
@@ -439,17 +439,22 @@ func decodeMathFromOutput(output []float32) string {
allChars[t] = maxIdx allChars[t] = maxIdx
} }
// 打印所有位置的识别结果 // 打印所有位置的识别结果(包括索引值)
debugStr := "DEBUG argmax: " debugStr := "DEBUG argmax: "
for _, idx := range allChars { for _, idx := range allChars {
if idx > 0 && idx <= len(CHARS) { if idx > 0 && idx <= len(CHARS) {
debugStr += string(CHARS[idx-1]) debugStr += fmt.Sprintf("%c", CHARS[idx-1])
} else { } else if idx == 0 {
debugStr += "_" debugStr += "_"
} else {
debugStr += fmt.Sprintf("[%d]", idx) // 显示越界索引
} }
} }
fmt.Println(debugStr) fmt.Println(debugStr)
// 打印原始索引值
fmt.Printf("DEBUG raw indices: %v\n", allChars[:20])
// CTC 解码: 跳过 blank (index 0) 和连续重复 // CTC 解码: 跳过 blank (index 0) 和连续重复
result := "" result := ""
lastIdx := -1 lastIdx := -1