Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
speech_nlu_parse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵文静
speech_nlu_parse
Commits
7a969c6a
Commit
7a969c6a
authored
Jun 27, 2025
by
赵文静
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改param,音乐传全部字段
parent
42091f61
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
59 deletions
+67
-59
CHANGELOG.md
CHANGELOG.md
+2
-0
c2c.http
c2c.http
+6
-6
main.go
main.go
+1
-1
model/speech.go
model/speech.go
+26
-22
service/speechNlu/domain.go
service/speechNlu/domain.go
+32
-30
No files found.
CHANGELOG.md
View file @
7a969c6a
...
...
@@ -2,6 +2,8 @@
## [0.0.1-beta.4] - 2025.6.26
### Changed
-
修改历史上的今天,修改限制判断
-
修改新闻增加上一个下一个
-
修改param,音乐传全部字段
## [0.0.1-beta.4] - 2025.6.24
### Changed
...
...
c2c.http
View file @
7a969c6a
...
...
@@ -10,7 +10,7 @@ Content-Type: application/json
},
"nluRet": {
"asr_recongize": "",
"text": "
几点了几点了几点了
"
"text": "
放张韶涵的暮色
"
}
},
"version": "v0"
...
...
@@ -24,8 +24,8 @@ X-AppKey: 391b50b5ed634fc49a3db7cfd6bc40db
{
"ip": "14.215.222.17",
"mac": "ece154a865eb",
"mid": "1
0f05
",
"query":"
历史上的今天
",
"mid": "1
1011
",
"query":"
播放上一首古诗
",
"requestId": "123456111"
}
...
...
@@ -39,7 +39,7 @@ X-AppKey: 391b50b5ed634fc49a3db7cfd6bc40db
"ip": "14.215.222.17",
"mac": "ece154a865eb",
"mid": "10f05",
"query":"
历史上的今天
",
"query":"
播放上一首古诗
",
"requestId": "123456111"
}
...
...
@@ -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;"
},
"nluRet": {
"text": "
几点了伦敦
"
"text": "
央视的新闻
"
},
"postProc": {}
}
...
...
@@ -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;"
},
"nluRet": {
"text": "播放
治愈
"
"text": "播放
上一首古诗
"
},
"postProc": {}
}
...
...
main.go
View file @
7a969c6a
...
...
@@ -207,7 +207,7 @@ func setupFlag() error {
flag
.
StringVar
(
&
serverTag
,
"tag"
,
""
,
"注册到注册中心的标签"
)
flag
.
StringVar
(
&
ip
,
"ip"
,
""
,
"IP"
)
flag
.
IntVar
(
&
port
,
"port"
,
0
,
"端口"
)
flag
.
StringVar
(
&
consulUrl
,
"consul"
,
"http://172.28.124.10
6
:8500"
,
"consul服务地址"
)
flag
.
StringVar
(
&
consulUrl
,
"consul"
,
"http://172.28.124.10
5
:8500"
,
"consul服务地址"
)
flag
.
StringVar
(
&
config
,
"config"
,
"env/v2,speech_nlu_parse/conf"
,
"指定要使用的配置文件路径"
)
flag
.
BoolVar
(
&
isVersion
,
"version"
,
false
,
"编译信息"
)
flag
.
StringVar
(
&
consulToken
,
"token"
,
"092288b5-824f-854c-39aa-a958afd9a633"
,
"consul token"
)
...
...
model/speech.go
View file @
7a969c6a
...
...
@@ -76,28 +76,32 @@ type SpeechWsResp struct {
ShouldEndSession
bool
`json:"shouldEndSession"`
Api
string
`json:"api"`
Command
*
struct
{
Param
*
struct
{
Volume
string
`json:"volume"`
Mode
string
`json:"mode"`
Object
string
`json:"object"`
Extra
string
`json:"extra"`
Version
string
`json:"version"`
Song
string
`json:"song"`
Singer
string
`json:"singer"`
Emotion
string
`json:"emotion"`
Album
string
`json:"album"`
Language
string
`json:"language"`
Age
string
`json:"age"`
Instrument
string
`json:"instrument"`
Author
string
`json:"author"`
Composer
string
`json:"composer"`
People
string
`json:"people"`
Area
string
`json:"area"`
Theme
string
`json:"theme"`
Style
string
`json:"style"`
Toplist
string
`json:"toplist"`
AgeRange
string
`json:"ageRange"`
}
`json:"param"`
Param
map
[
string
]
interface
{}
`json:"param"`
//Param *struct {
// Volume string `json:"volume"`
// Mode string `json:"mode"`
// Object string `json:"object"`
// Extra string `json:"extra"`
// Version string `json:"version"`
// Song string `json:"song"`
// Singer string `json:"singer"`
// Emotion string `json:"emotion"`
// Album string `json:"album"`
// Language string `json:"language"`
// Age string `json:"age"`
// Instrument string `json:"instrument"`
// Author string `json:"author"`
// Composer string `json:"composer"`
// People string `json:"people"`
// Area string `json:"area"`
// Theme string `json:"theme"`
// Style string `json:"style"`
// Toplist string `json:"toplist"`
// AgeRange string `json:"ageRange"`
// Gender string `json:"gender"`
// SuitableAge string `json:"suitable_age"`
// Scene string `json:"scene"`
//} `json:"param"`
Api
string
`json:"api"`
}
`json:"command"`
}
`json:"dm"`
...
...
service/speechNlu/domain.go
View file @
7a969c6a
...
...
@@ -224,6 +224,24 @@ func newsDomain(params *model.SpeechDomainParams) []byte {
return
replyWithChat
(
error_reply
,
"doudi"
)
}
query
:=
params
.
SpeechWsResp
.
Dm
.
Input
if
params
.
CheckDmCommand
()
{
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
!=
""
{
switch
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
{
case
"DUI.MediaController.Pause"
:
return
transformGreeProtocolReply
(
query
,
"PlayControl"
,
"control_pause"
,
nil
)
case
"DUI.MediaController.Play"
:
return
transformGreeProtocolReply
(
query
,
"PlayControl"
,
"control_resume"
,
nil
)
case
"DUI.MediaController.Stop"
:
return
transformGreeProtocolReply
(
query
,
"PlayControl"
,
"control_stop"
,
nil
)
case
"DUI.MediaController.Next"
,
"DUI.MediaController.Switch"
:
return
transformGreeProtocolReply
(
query
,
"PlayControl"
,
"control_next"
,
nil
)
case
"DUI.MediaController.Prev"
:
return
transformGreeProtocolReply
(
query
,
"PlayControl"
,
"control_previous"
,
nil
)
}
}
}
res
.
Header
.
Semantic
.
Domain
=
"news"
res
.
Header
.
Semantic
.
Intent
=
"search"
res
.
Header
.
Semantic
.
SkillId
=
res
.
Header
.
Semantic
.
Domain
+
"."
+
res
.
Header
.
Semantic
.
Intent
...
...
@@ -350,22 +368,6 @@ func ancientpoemDomain(params *model.SpeechDomainParams) []byte {
}
}
//if len(params.SpeechWsResp.Dm.Widget.Content) > 0 {
// for i := 0; i < len(params.SpeechWsResp.Dm.Widget.Content); i++ {
// res.ListItems = append(res.ListItems, map[string]interface{}{
// "url": params.SpeechWsResp.Dm.Widget.Content[i].LinkUrl,
// "title": params.SpeechWsResp.Dm.Widget.Content[i].Title,
// "content": params.SpeechWsResp.Dm.Widget.Content[i].Text,
// "author": params.SpeechWsResp.Dm.Widget.Content[i].Author,
// "dynasty": params.SpeechWsResp.Dm.Widget.Content[i].Extra.Dynasty,
// "mediaId": "",
// "type": params.SpeechWsResp.Dm.Widget.Type, //原来是 AUDIO,看看是否能播放
// //思必驰的没有回复话术
// //"content": params.Dm.Widget.Content[i].TextContent,
// })
// }
//}
res
.
Header
.
Semantic
.
SkillId
=
res
.
Header
.
Semantic
.
Domain
+
"."
+
res
.
Header
.
Semantic
.
Intent
return
Marshal
(
params
,
res
)
}
...
...
@@ -505,8 +507,8 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
return
replyWithChat
(
error_reply
,
"doudi"
)
}
api
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
extra
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Extra
object
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Object
extra
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"extra"
]
.
(
string
)
object
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"object"
]
.
(
string
)
var
extraParam
model
.
ExtraParams
if
err
:=
json
.
Unmarshal
([]
byte
(
extra
),
&
extraParam
);
err
!=
nil
{
...
...
@@ -715,13 +717,13 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
if
!
params
.
CheckCommandParam
()
{
return
replyWithChat
(
error_reply
,
"doudi"
)
}
else
{
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
!=
""
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.MediaController.SetVolume"
{
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
"-"
)
||
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
"+"
)
{
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
!=
""
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.MediaController.SetVolume"
{
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
),
"-"
)
||
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
"+"
)
{
pattern
:=
`([+-]?)(\d+)`
// 分组1:符号(+/-),分组2:数字
re
:=
regexp
.
MustCompile
(
pattern
)
// 查找所有匹配项
matches
:=
re
.
FindAllStringSubmatch
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
-
1
)
matches
:=
re
.
FindAllStringSubmatch
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
-
1
)
var
sign
,
numStr
,
action
string
for
_
,
match
:=
range
matches
{
...
...
@@ -742,22 +744,22 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
}
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
action
,
&
semanticParams
)
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
==
"max"
{
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
==
"max"
{
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
"control_riseVolMax"
,
nil
)
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
==
"min"
{
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
==
"min"
{
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
"control_reduceVolMin"
,
nil
)
}
else
{
semanticParams
:=
make
(
map
[
string
]
interface
{})
// 百分数
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
"%"
)
{
parts
:=
strings
.
SplitN
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
"%"
,
2
)
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
"%"
)
{
parts
:=
strings
.
SplitN
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
"%"
,
2
)
semanticParams
[
"degree"
]
=
model
.
ParamsStr
{
Origin
:
parts
[
0
],
Norm
:
parts
[
0
],
Code
:
0
}
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
"control_setVol"
,
&
semanticParams
)
}
// 分数
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
"/"
)
{
num
,
err
:=
fractionToPercent
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
)
if
strings
.
Contains
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
"/"
)
{
num
,
err
:=
fractionToPercent
(
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
)
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
...
...
@@ -772,12 +774,12 @@ func globalCtrlDomain(params *model.SpeechDomainParams) []byte {
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
"control_setVol"
,
&
semanticParams
)
}
semanticParams
[
"degree"
]
=
model
.
ParamsStr
{
Origin
:
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
Norm
:
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Volume
,
Code
:
0
}
semanticParams
[
"degree"
]
=
model
.
ParamsStr
{
Origin
:
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
),
Norm
:
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"volume"
]
.
(
string
)
,
Code
:
0
}
return
transformGreeProtocolReply
(
query
,
"UniversalControl"
,
"control_setVol"
,
&
semanticParams
)
}
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.System.Sounds.OpenMode"
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Mode
==
"静音模式"
{
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.System.Sounds.OpenMode"
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"mode"
]
.
(
string
)
==
"静音模式"
{
return
transformGreeProtocolReply
(
query
,
"SystemControl"
,
"control_volumeOff"
,
nil
)
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.System.Sounds.CloseMode"
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Mode
==
"静音模式"
{
}
else
if
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
==
"DUI.System.Sounds.CloseMode"
&&
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
[
"mode"
]
.
(
string
)
==
"静音模式"
{
return
transformGreeProtocolReply
(
query
,
"SystemControl"
,
"control_volumeOn"
,
nil
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment