debug: show raw indices and fix boundary check
This commit is contained in:
@@ -439,17 +439,22 @@ func decodeMathFromOutput(output []float32) string {
|
||||
allChars[t] = maxIdx
|
||||
}
|
||||
|
||||
// 打印所有位置的识别结果
|
||||
// 打印所有位置的识别结果(包括索引值)
|
||||
debugStr := "DEBUG argmax: "
|
||||
for _, idx := range allChars {
|
||||
if idx > 0 && idx <= len(CHARS) {
|
||||
debugStr += string(CHARS[idx-1])
|
||||
} else {
|
||||
debugStr += fmt.Sprintf("%c", CHARS[idx-1])
|
||||
} else if idx == 0 {
|
||||
debugStr += "_"
|
||||
} else {
|
||||
debugStr += fmt.Sprintf("[%d]", idx) // 显示越界索引
|
||||
}
|
||||
}
|
||||
fmt.Println(debugStr)
|
||||
|
||||
// 打印原始索引值
|
||||
fmt.Printf("DEBUG raw indices: %v\n", allChars[:20])
|
||||
|
||||
// CTC 解码: 跳过 blank (index 0) 和连续重复
|
||||
result := ""
|
||||
lastIdx := -1
|
||||
|
||||
Reference in New Issue
Block a user