This commit is contained in:
邹宗楠
2022-07-28 13:52:20 +08:00
parent 16fa4f09ed
commit 24341f5d1c

View File

@@ -479,33 +479,33 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
result = strings.ReplaceAll(result, byteSignQrRightE, hexSignQrEnd) result = strings.ReplaceAll(result, byteSignQrRightE, hexSignQrEnd)
} }
// 固定模板输出语音 3c736f756e643e<sound> 3634 </sound>3c2f736f756e643e // 固定模板输出语音 3c736f756e643e<sound> 3634 </sound>3c2f736f756e643e
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) { //if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
soundStr := "" // soundStr := ""
for _, v1 := range strings.Split(result, byteSignSoundE) { // for _, v1 := range strings.Split(result, byteSignSoundE) {
v1 += byteSignSoundE // v1 += byteSignSoundE
if sounds := regexpSound.FindStringSubmatch(v1); len(sounds) > 0 { // if sounds := regexpSound.FindStringSubmatch(v1); len(sounds) > 0 {
sound := sounds[1] // sound := sounds[1]
//先把结束标签消了 // //先把结束标签消了
resultV1 := strings.ReplaceAll(v1, byteSignSoundE, "") // resultV1 := strings.ReplaceAll(v1, byteSignSoundE, "")
// 将语音包转换为十六进制 // // 将语音包转换为十六进制
voice := "" // voice := ""
for _, v := range strings.Split(sound, "2c") { // for _, v := range strings.Split(sound, "2c") {
voice += hexSignSoundSolidification // voice += hexSignSoundSolidification
soundNum, _ := hex.DecodeString(v) // 十六进制转字符串 // soundNum, _ := hex.DecodeString(v) // 十六进制转字符串
intSound, _ := strconv.ParseInt(string(soundNum), 10, 64) // intSound, _ := strconv.ParseInt(string(soundNum), 10, 64)
int16Sound := strconv.FormatInt(intSound, 16) // int16Sound := strconv.FormatInt(intSound, 16)
if intSound < PrintSoundMaxNumber { // 小于十六补位 // if intSound < PrintSoundMaxNumber { // 小于十六补位
voice += PlaceFillingParam + int16Sound // voice += PlaceFillingParam + int16Sound
} else { // } else {
voice += int16Sound // voice += int16Sound
} // }
} // }
soundParam := strings.ReplaceAll(resultV1, sound, "") // soundParam := strings.ReplaceAll(resultV1, sound, "")
soundStr += strings.ReplaceAll(soundParam, byteSignSound, voice) // soundStr += strings.ReplaceAll(soundParam, byteSignSound, voice)
} // }
} // }
result = soundStr // result = soundStr
} //}
// 自动合成语音功能 // 自动合成语音功能
//if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) { //if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
// if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 { // if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {