Commit f758d379 authored by 赵文静's avatar 赵文静

修改param,音乐传全部字段

parent 7a969c6a
Pipeline #5487 passed with stage
in 0 seconds
...@@ -39,7 +39,7 @@ X-AppKey: 391b50b5ed634fc49a3db7cfd6bc40db ...@@ -39,7 +39,7 @@ X-AppKey: 391b50b5ed634fc49a3db7cfd6bc40db
"ip": "14.215.222.17", "ip": "14.215.222.17",
"mac": "ece154a865eb", "mac": "ece154a865eb",
"mid": "10f05", "mid": "10f05",
"query":"播放上一首古诗", "query":"关闭静音模式",
"requestId": "123456111" "requestId": "123456111"
} }
...@@ -60,7 +60,7 @@ Content-Type: application/json ...@@ -60,7 +60,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxxx;macWifi=28b77c218ed1;mid=10f05;vender=7e000025;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;" "trafficParameter": "mode=childxxx;macWifi=28b77c218ed1;mid=10f05;vender=7e000025;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
}, },
"nluRet": { "nluRet": {
"text": "央视的新闻" "text": "打开静音模式"
}, },
"postProc": {} "postProc": {}
} }
...@@ -101,7 +101,7 @@ Content-Type: application/json ...@@ -101,7 +101,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxx;macWifi=ece154a73d38;mid=11011;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;" "trafficParameter": "mode=childxx;macWifi=ece154a73d38;mid=11011;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
}, },
"nluRet": { "nluRet": {
"text": "播放上一首古诗" "text": "打开静音模式"
}, },
"postProc": {} "postProc": {}
} }
......
...@@ -507,8 +507,15 @@ func alarmDomain(params *model.SpeechDomainParams) []byte { ...@@ -507,8 +507,15 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
return replyWithChat(error_reply, "doudi") return replyWithChat(error_reply, "doudi")
} }
api := params.SpeechWsResp.Dm.Command.Api api := params.SpeechWsResp.Dm.Command.Api
extra := params.SpeechWsResp.Dm.Command.Param["extra"].(string) var extra, object string
object := params.SpeechWsResp.Dm.Command.Param["object"].(string) if v, ok := params.SpeechWsResp.Dm.Command.Param["extra"]; ok {
extra = v.(string)
}
if v1, ok := params.SpeechWsResp.Dm.Command.Param["object"]; ok {
object = v1.(string)
}
//extra := params.SpeechWsResp.Dm.Command.Param["extra"].(string)
//object := params.SpeechWsResp.Dm.Command.Param["object"].(string)
var extraParam model.ExtraParams var extraParam model.ExtraParams
if err := json.Unmarshal([]byte(extra), &extraParam); err != nil { if err := json.Unmarshal([]byte(extra), &extraParam); err != nil {
...@@ -717,13 +724,21 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte { ...@@ -717,13 +724,21 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
if !params.CheckCommandParam() { if !params.CheckCommandParam() {
return replyWithChat(error_reply, "doudi") return replyWithChat(error_reply, "doudi")
} else { } else {
if params.SpeechWsResp.Dm.Command.Param["volume"].(string) != "" && params.SpeechWsResp.Dm.Command.Api == "DUI.MediaController.SetVolume" { var volume, mode string
if strings.Contains(params.SpeechWsResp.Dm.Command.Param["volume"].(string), "-") || strings.Contains(params.SpeechWsResp.Dm.Command.Param["volume"].(string), "+") { if v, ok := params.SpeechWsResp.Dm.Command.Param["volume"]; ok {
volume = v.(string)
}
if v1, ok := params.SpeechWsResp.Dm.Command.Param["mode"]; ok {
mode = v1.(string)
}
if volume != "" && params.SpeechWsResp.Dm.Command.Api == "DUI.MediaController.SetVolume" {
if strings.Contains(volume, "-") || strings.Contains(volume, "+") {
pattern := `([+-]?)(\d+)` // 分组1:符号(+/-),分组2:数字 pattern := `([+-]?)(\d+)` // 分组1:符号(+/-),分组2:数字
re := regexp.MustCompile(pattern) re := regexp.MustCompile(pattern)
// 查找所有匹配项 // 查找所有匹配项
matches := re.FindAllStringSubmatch(params.SpeechWsResp.Dm.Command.Param["volume"].(string), -1) matches := re.FindAllStringSubmatch(volume, -1)
var sign, numStr, action string var sign, numStr, action string
for _, match := range matches { for _, match := range matches {
...@@ -735,6 +750,8 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte { ...@@ -735,6 +750,8 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
if numStr != "" { if numStr != "" {
semanticParams["degree"] = model.ParamsStr{Origin: numStr, Norm: numStr, Code: 0} semanticParams["degree"] = model.ParamsStr{Origin: numStr, Norm: numStr, Code: 0}
} else {
semanticParams["degree"] = model.ParamsStr{Origin: "一", Norm: "1", Code: 0}
} }
if sign == "-" { if sign == "-" {
...@@ -744,22 +761,22 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte { ...@@ -744,22 +761,22 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
} }
return transformGreeProtocolReply(query, "UniversalControl", action, &semanticParams) return transformGreeProtocolReply(query, "UniversalControl", action, &semanticParams)
} else if params.SpeechWsResp.Dm.Command.Param["volume"].(string) == "max" { } else if volume == "max" {
return transformGreeProtocolReply(query, "UniversalControl", "control_riseVolMax", nil) return transformGreeProtocolReply(query, "UniversalControl", "control_riseVolMax", nil)
} else if params.SpeechWsResp.Dm.Command.Param["volume"].(string) == "min" { } else if volume == "min" {
return transformGreeProtocolReply(query, "UniversalControl", "control_reduceVolMin", nil) return transformGreeProtocolReply(query, "UniversalControl", "control_reduceVolMin", nil)
} else { } else {
semanticParams := make(map[string]interface{}) semanticParams := make(map[string]interface{})
// 百分数 // 百分数
if strings.Contains(params.SpeechWsResp.Dm.Command.Param["volume"].(string), "%") { if strings.Contains(volume, "%") {
parts := strings.SplitN(params.SpeechWsResp.Dm.Command.Param["volume"].(string), "%", 2) parts := strings.SplitN(volume, "%", 2)
semanticParams["degree"] = model.ParamsStr{Origin: parts[0], Norm: parts[0], Code: 0} semanticParams["degree"] = model.ParamsStr{Origin: parts[0], Norm: parts[0], Code: 0}
return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams) return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams)
} }
// 分数 // 分数
if strings.Contains(params.SpeechWsResp.Dm.Command.Param["volume"].(string), "/") { if strings.Contains(volume, "/") {
num, err := fractionToPercent(params.SpeechWsResp.Dm.Command.Param["volume"].(string)) num, err := fractionToPercent(volume)
if err != nil { if err != nil {
global.Logger.WithFields(logger.Fields{ global.Logger.WithFields(logger.Fields{
"requestId": params.RequestId, "requestId": params.RequestId,
...@@ -774,12 +791,12 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte { ...@@ -774,12 +791,12 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams) return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams)
} }
semanticParams["degree"] = model.ParamsStr{Origin: params.SpeechWsResp.Dm.Command.Param["volume"].(string), Norm: params.SpeechWsResp.Dm.Command.Param["volume"].(string), Code: 0} semanticParams["degree"] = model.ParamsStr{Origin: volume, Norm: volume, Code: 0}
return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams) return transformGreeProtocolReply(query, "UniversalControl", "control_setVol", &semanticParams)
} }
} else if params.SpeechWsResp.Dm.Command.Api == "DUI.System.Sounds.OpenMode" && params.SpeechWsResp.Dm.Command.Param["mode"].(string) == "静音模式" { } else if params.SpeechWsResp.Dm.Command.Api == "DUI.System.Sounds.OpenMode" && mode == "静音模式" {
return transformGreeProtocolReply(query, "SystemControl", "control_volumeOff", nil) return transformGreeProtocolReply(query, "SystemControl", "control_volumeOff", nil)
} else if params.SpeechWsResp.Dm.Command.Api == "DUI.System.Sounds.CloseMode" && params.SpeechWsResp.Dm.Command.Param["mode"].(string) == "静音模式" { } else if params.SpeechWsResp.Dm.Command.Api == "DUI.System.Sounds.CloseMode" && mode == "静音模式" {
return transformGreeProtocolReply(query, "SystemControl", "control_volumeOn", nil) return transformGreeProtocolReply(query, "SystemControl", "control_volumeOn", nil)
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment