修改语音配置

This commit is contained in:
邹宗楠
2022-08-04 17:26:19 +08:00
parent e8deb61cad
commit f1761fa154
2 changed files with 14 additions and 32 deletions

View File

@@ -482,9 +482,9 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
result = strings.ReplaceAll(result, byteSignQrRight, hexSignQrRight+hexSignQr+hexLenqr+"00")
result = strings.ReplaceAll(result, byteSignQrRightE, hexSignQrEnd)
}
// 固定模板输出语音 3c736f756e643e<sound> 3634 </sound>3c2f736f756e643e
// 固定模板输出语音
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
soundStr := ""
var soundStr []string
for _, v1 := range strings.Split(result, byteSignSoundE) {
v1 += byteSignSoundE
if sounds := regexpSound.FindStringSubmatch(v1); len(sounds) > 0 {
@@ -505,10 +505,17 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
}
}
soundParam := strings.ReplaceAll(resultV1, sound, "")
soundStr += strings.ReplaceAll(soundParam, byteSignSound, voice)
soundStr = append(soundStr, strings.ReplaceAll(soundParam, byteSignSound, voice))
}
}
result = soundStr
result = strings.ReplaceAll(result, byteSignSound, "*")
result = strings.ReplaceAll(result, byteSignSoundE, "&")
for _, v := range soundStr {
start := strings.Index(result, "*")
end := strings.Index(result, "&")
result = strings.Replace(result, result[start:end+1], v, 1)
}
}
// 自动合成语音功能
//if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
@@ -566,8 +573,8 @@ func int2h8l8(i int64) (h, l string) {
}
begin8 := origin2[:8]
end8 := origin2[8:]
r1, _ := strconv.ParseInt(begin8, 2, 64)
r2, _ := strconv.ParseInt(end8, 2, 64)
r1, _ := strconv.ParseInt(begin8, 2, 32)
r2, _ := strconv.ParseInt(end8, 2, 32)
h = fmt.Sprintf("%x", r1)
l = fmt.Sprintf("%x", r2)
if len(h)%2 != 0 {

View File

@@ -6,7 +6,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"strconv"
"strings"
"testing"
"unicode/utf8"
)
@@ -16,7 +15,7 @@ func TestPrintMsg(t *testing.T) {
msg := &model.PrintMsg{
ModelIDCULD: model.ModelIDCULD{},
PrintNo: "20220707000002",
Content: "<sound>61</sound><sound>62</sound>",
Content: "<sound>1,2,3</sound><center>居中文字</center><sound>4,5,6</sound><center>居中</center>",
OrderNo: "9999999991", // 2147483648111
Status: 0,
Comment: "",
@@ -25,7 +24,6 @@ func TestPrintMsg(t *testing.T) {
data, err := buildMsg(msg)
fmt.Println("data=", fmt.Sprintf("%s", string(data...)))
fmt.Println("data=", string(data))
fmt.Println("err=", err)
}
@@ -63,28 +61,5 @@ func TestCheckSum(t *testing.T) {
}
func TestTen216(t *testing.T) {
fmt.Println(toHex(16))
}
func toHex(ten int) string {
m := 0
hex := make([]int, 0)
for {
m = ten % 16
ten = ten / 16
if ten == 0 {
hex = append(hex, m)
break
}
hex = append(hex, m)
}
hexStr := []string{}
for i := len(hex) - 1; i >= 0; i-- {
if hex[i] >= 10 {
hexStr = append(hexStr, fmt.Sprintf("%c", 'A'+hex[i]-10))
} else {
hexStr = append(hexStr, fmt.Sprintf("%d", hex[i]))
}
}
return strings.Join(hexStr, "")
}