【修改语音识别字符匹配结束位置索引】

This commit is contained in:
weizhihong 2023-04-11 14:00:43 +08:00
parent 83c5d6e644
commit f38c3bd1ba

View File

@ -122,16 +122,16 @@ public class VoiceDiscriminateResult {
String pinYin = null;
for (int i = 0, len = contentPinYinArr.length; i < len; i ++) {
pinYin = contentPinYinArr[i];
if (Objects.equals(group.substring(readIndex, readIndex + pinYin.length()), pinYin)) {
if (readIndex == 0) {
if (Objects.equals(group.substring(readIndex, readIndex + pinYin.length()), pinYin)) { // 字符一致
if (readIndex == 0) { // 如果是0代表刚开始匹配记录开始索引
indexArr[0] = i;
}
readIndex = readIndex + pinYin.length();
} else {
} else { // 字符不一致重新匹配位置
readIndex = 0;
}
if (readIndex == group.length()) { // 结束位置
indexArr[1] = i + 1;
indexArr[1] = i;
break;
}
}