This commit is contained in:
邹宗楠
2022-07-26 17:19:19 +08:00
parent e7cc5c9932
commit 9f7a64cbbe

View File

@@ -479,24 +479,8 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
sound := sounds[1]
//printer := model.Printer{}
//printer.Volume = 4
//printer.Sound = "sounda"
//if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
//先把结束标签消了
result = strings.ReplaceAll(result, byteSignSoundE, "") // 3c736f756e643e 3230 3c736f756e643e
//fd 固定
//001a (声音数据长度高八位低八位)
//0101 固定
//soundPrefix := ""
//if printer.Sound != "" {
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
//} else {
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
//}
//hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
//hexPrefixStr := hex.EncodeToString(hexPrefix)
// 将语音包转换为十六进制
voice := ""
for _, v := range strings.Split(sound, "2c") {
@@ -505,24 +489,9 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
int16Sound := strconv.FormatInt(intSound, 16)
voice += int16Sound
}
fmt.Println("voice=========", voice)
//voiceDataGBK, _ := jxutils.Utf8ToGbk([]byte(voice))
//voiceData := hex.EncodeToString(voiceDataGBK)
//[8]sounda14 ->5b385d736f756e64613134
//hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
//hexPrefixStr := hex.EncodeToString(hexPrefix)
//realSound := hexPrefixStr + sound
//allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
//if len(allLen) < 2 {
// allLen = "0" + allLen
//}
//soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
//result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
globals.SugarLogger.Debug("voice==================", voice)
result = strings.ReplaceAll(result, sound, "")
result = strings.ReplaceAll(result, byteSignSound, hexSignSoundSolidification+"14")
//}
}
}
// 自动合成语音功能