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
614196cc
Commit
614196cc
authored
May 16, 2025
by
赵文静
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充domain
parent
14380081
Pipeline
#5211
passed with stage
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
26 deletions
+106
-26
service/service.go
service/service.go
+3
-2
service/speechNlu/constant.go
service/speechNlu/constant.go
+23
-20
service/speechNlu/domain.go
service/speechNlu/domain.go
+73
-2
service/speechNlu/register.go
service/speechNlu/register.go
+3
-0
service/speechNlu/speech.go
service/speechNlu/speech.go
+1
-1
service/speechNlu/speechWs.go
service/speechNlu/speechWs.go
+3
-1
No files found.
service/service.go
View file @
614196cc
...
@@ -536,11 +536,12 @@ func (TencentNlu) TencentNluParseStream(stream proto.TencentNlu_TencentNluParseS
...
@@ -536,11 +536,12 @@ func (TencentNlu) TencentNluParseStream(stream proto.TencentNlu_TencentNluParseS
}
}
sessionId
:=
tMetaData
.
SessionId
sessionId
:=
tMetaData
.
SessionId
vender
:=
tMetaData
.
Vender
vender
:=
tMetaData
.
Vender
var
appKey
,
auth
,
dsn
,
qua
,
requestId
,
mid
,
mac
string
var
appKey
,
auth
,
dsn
,
qua
,
requestId
,
mid
,
mac
,
ip
string
qua
=
"QV=3&PL=ADR&PR=chvoice&VE=7.6&VN=3350&PP=com.geli.mtt&DE=SPEAKER&SP=3"
qua
=
"QV=3&PL=ADR&PR=chvoice&VE=7.6&VN=3350&PP=com.geli.mtt&DE=SPEAKER&SP=3"
requestId
=
tMetaData
.
RequestId
requestId
=
tMetaData
.
RequestId
mid
=
tMetaData
.
Mid
mid
=
tMetaData
.
Mid
mac
=
tMetaData
.
MacWifi
mac
=
tMetaData
.
MacWifi
ip
=
tMetaData
.
Ip
// 查询key和secret
// 查询key和secret
//dingDangBot, ok := global.DingDangBot.Get(tMetaData.Mid, tMetaData.Vender)
//dingDangBot, ok := global.DingDangBot.Get(tMetaData.Mid, tMetaData.Vender)
//if ok {
//if ok {
...
@@ -609,7 +610,7 @@ func (TencentNlu) TencentNluParseStream(stream proto.TencentNlu_TencentNluParseS
...
@@ -609,7 +610,7 @@ func (TencentNlu) TencentNluParseStream(stream proto.TencentNlu_TencentNluParseS
speechNluWs
:=
speechNlu
.
SpeechNlpWs
{}
speechNluWs
:=
speechNlu
.
SpeechNlpWs
{}
var
nlpWsConn
*
websocket
.
Conn
var
nlpWsConn
*
websocket
.
Conn
nlpWsConn
,
err
=
speechNluWs
.
SpeechWs
(
mac
)
nlpWsConn
,
err
=
speechNluWs
.
SpeechWs
(
mac
,
ip
)
if
err
!=
nil
{
if
err
!=
nil
{
global
.
Logger
.
Errorf
(
"speechWs.SpeechWs error. %v"
,
err
)
global
.
Logger
.
Errorf
(
"speechWs.SpeechWs error. %v"
,
err
)
return
err
return
err
...
...
service/speechNlu/constant.go
View file @
614196cc
...
@@ -68,26 +68,29 @@ const (
...
@@ -68,26 +68,29 @@ const (
CHAT
=
"闲聊全库"
CHAT
=
"闲聊全库"
CALENDAR
=
"日历"
CALENDAR
=
"日历"
NEWS
=
"新闻"
NEWS
=
"新闻"
ANCIENTPOEM
=
"诗词"
ANCIENTPOEM
=
"诗词"
SPORTS
=
"sports"
SPORTS
=
"sports"
ASTRO
=
"星座"
ASTRO
=
"星座"
STOCK
=
"stock"
STOCK
=
"stock"
TRANSLATE
=
"翻译大全"
TRANSLATE
=
"翻译大全"
ALARM
=
"提醒"
ALARM
=
"提醒"
SCIENCE
=
"计算器"
SCIENCE
=
"计算器"
CHENGYU
=
"成语"
CHENGYU
=
"成语"
BAIKE
=
"百科"
BAIKE
=
"百科"
FM
=
"网络电台"
FM
=
"网络电台"
CHILDMUSIC
=
"儿歌"
CHILDMUSIC
=
"儿歌"
GLOBALCTRL
=
"中控"
GLOBALCTRL
=
"中控"
PlayCTRL
=
"播放控制"
PlayCTRL
=
"播放控制"
MUSIC
=
"音乐"
MUSIC
=
"音乐"
HELP
=
"产品形象"
HELP
=
"产品形象"
STORY
=
"故事"
STORY
=
"故事"
FINANCE
=
"汇率"
FINANCE
=
"汇率"
CONVERT
=
"单位换算"
CONVERT
=
"单位换算"
HOLIDAY
=
"节假日查询"
HOLIDAY
=
"节假日查询"
SLEEPMUSIC
=
"声音博物馆"
RELATION
=
"亲戚关系计算"
WASTESORTING
=
"垃圾分类"
SOUND
=
"sound"
SOUND
=
"sound"
ALMANAC
=
"almanac"
ALMANAC
=
"almanac"
...
...
service/speechNlu/domain.go
View file @
614196cc
...
@@ -376,8 +376,6 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
...
@@ -376,8 +376,6 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
UpdateSession
(
params
.
Mac
,
params
.
SpeechWsResp
.
SessionId
)
UpdateSession
(
params
.
Mac
,
params
.
SpeechWsResp
.
SessionId
)
return
Marshal
(
params
,
&
result
)
return
Marshal
(
params
,
&
result
)
}
}
fmt
.
Println
(
"1111111111111111111111111"
)
fmt
.
Println
(
params
.
SpeechWsResp
.
SessionId
)
if
!
params
.
CheckDm
()
||
!
params
.
CheckCommandParam
()
{
if
!
params
.
CheckDm
()
||
!
params
.
CheckCommandParam
()
{
return
replyWithChat
(
error_reply
,
"doudi"
)
return
replyWithChat
(
error_reply
,
"doudi"
)
...
@@ -791,6 +789,61 @@ func musicDomain(params *model.SpeechDomainParams) []byte {
...
@@ -791,6 +789,61 @@ func musicDomain(params *model.SpeechDomainParams) []byte {
return
Marshal
(
params
,
&
result
)
return
Marshal
(
params
,
&
result
)
}
}
func
sleepMusicDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
res
,
err
:=
baseParse
(
params
)
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"mac"
:
params
.
Mac
,
"mid"
:
params
.
Mid
,
"vender"
:
params
.
MidType
,
})
.
Error
(
"fmDomain baseParse error."
)
return
replyWithChat
(
error_reply
,
"doudi"
)
}
var
result
model
.
ResponseBody
result
.
Header
.
Semantic
.
Code
=
0
result
.
Header
.
Semantic
.
Domain
=
"music"
result
.
Header
.
Semantic
.
Intent
=
"SleepingMusic.control_searchTheme"
result
.
Header
.
Semantic
.
Msg
=
speech_nlu_parse
result
.
Header
.
Semantic
.
SessionComplete
=
params
.
SpeechWsResp
.
Dm
.
ShouldEndSession
result
.
Header
.
Semantic
.
SkillId
=
"SleepingMusic.control_searchTheme"
result
.
ListItems
=
make
([]
map
[
string
]
interface
{},
0
)
sliceData
,
isSlice
:=
params
.
SpeechWsResp
.
Dm
.
Widget
.
Content
.
([]
interface
{})
if
!
isSlice
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"mac"
:
params
.
Mac
,
"mid"
:
params
.
Mid
,
"vender"
:
params
.
MidType
,
})
.
Error
(
"params.SpeechWsResp.Dm.Widget.Content不是数组类型"
)
if
res
.
ResponseText
!=
""
{
return
replyWithChat
(
res
.
ResponseText
,
"doudi"
)
}
return
replyWithChat
(
error_reply
,
"doudi"
)
}
for
_
,
item
:=
range
sliceData
{
itemBytes
,
_
:=
json
.
Marshal
(
item
)
var
con
model
.
Content
if
err
:=
json
.
Unmarshal
(
itemBytes
,
&
con
);
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"mac"
:
params
.
Mac
,
"mid"
:
params
.
Mid
,
"vender"
:
params
.
MidType
,
})
.
Errorf
(
"json.Unmarshal元素解析失败: %v"
,
err
)
return
replyWithChat
(
error_reply
,
"doudi"
)
}
res
.
ListItems
=
append
(
res
.
ListItems
,
map
[
string
]
interface
{}{
"url"
:
con
.
LinkUrl
,
"title"
:
con
.
Title
,
})
}
return
Marshal
(
params
,
&
result
)
}
func
financeDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
func
financeDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
if
!
params
.
CheckDm
()
{
if
!
params
.
CheckDm
()
{
return
replyWithChat
(
error_reply
,
"doudi"
)
return
replyWithChat
(
error_reply
,
"doudi"
)
...
@@ -845,6 +898,24 @@ func holidayDomain(params *model.SpeechDomainParams) []byte {
...
@@ -845,6 +898,24 @@ func holidayDomain(params *model.SpeechDomainParams) []byte {
return
Marshal
(
params
,
&
result
)
return
Marshal
(
params
,
&
result
)
}
}
func
speechOtherDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
if
!
params
.
CheckDm
()
{
return
replyWithChat
(
error_reply
,
"doudi"
)
}
var
result
model
.
ResponseBody
result
.
Header
.
Semantic
.
Code
=
0
result
.
Header
.
Semantic
.
Domain
=
"chat"
result
.
Header
.
Semantic
.
Intent
=
"chat"
result
.
Header
.
Semantic
.
Msg
=
speech_nlu_parse
result
.
Header
.
Semantic
.
SessionComplete
=
params
.
SpeechWsResp
.
Dm
.
ShouldEndSession
//params.SpeechWsResp.Dm.ShouldEndSession
result
.
Header
.
Semantic
.
SkillId
=
result
.
Header
.
Semantic
.
Domain
+
"."
+
result
.
Header
.
Semantic
.
Intent
result
.
ResponseText
=
params
.
SpeechWsResp
.
Dm
.
Nlg
result
.
AsrRecongize
=
params
.
SpeechWsResp
.
Dm
.
Input
return
Marshal
(
params
,
&
result
)
}
func
helpDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
func
helpDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
resultTextStr
:=
"我可以控制空调开机、播放音乐、查询时间天气、调节温度,设置模式,例如您可以对我说,空调开机。"
resultTextStr
:=
"我可以控制空调开机、播放音乐、查询时间天气、调节温度,设置模式,例如您可以对我说,空调开机。"
return
replyWithChat
(
resultTextStr
,
"chat.chat"
)
return
replyWithChat
(
resultTextStr
,
"chat.chat"
)
...
...
service/speechNlu/register.go
View file @
614196cc
...
@@ -43,11 +43,14 @@ func register() {
...
@@ -43,11 +43,14 @@ func register() {
DomainRegister
(
GLOBALCTRL
,
globalCtrlDomain
)
DomainRegister
(
GLOBALCTRL
,
globalCtrlDomain
)
DomainRegister
(
PlayCTRL
,
playCtrlDomain
)
DomainRegister
(
PlayCTRL
,
playCtrlDomain
)
DomainRegister
(
MUSIC
,
musicDomain
)
DomainRegister
(
MUSIC
,
musicDomain
)
DomainRegister
(
SLEEPMUSIC
,
sleepMusicDomain
)
DomainRegister
(
HELP
,
helpDomain
)
DomainRegister
(
HELP
,
helpDomain
)
DomainRegister
(
STORY
,
fmDomain
)
DomainRegister
(
STORY
,
fmDomain
)
DomainRegister
(
FINANCE
,
financeDomain
)
DomainRegister
(
FINANCE
,
financeDomain
)
DomainRegister
(
CONVERT
,
convertDomain
)
DomainRegister
(
CONVERT
,
convertDomain
)
DomainRegister
(
HOLIDAY
,
holidayDomain
)
DomainRegister
(
HOLIDAY
,
holidayDomain
)
DomainRegister
(
RELATION
,
speechOtherDomain
)
DomainRegister
(
WASTESORTING
,
speechOtherDomain
)
//
//
//DomainRegisterV2(CHAT, chatDomainV2)
//DomainRegisterV2(CHAT, chatDomainV2)
...
...
service/speechNlu/speech.go
View file @
614196cc
...
@@ -79,7 +79,7 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) {
...
@@ -79,7 +79,7 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) {
speechNluWs
:=
SpeechNlpWs
{}
speechNluWs
:=
SpeechNlpWs
{}
var
nlpWsConn
*
websocket
.
Conn
var
nlpWsConn
*
websocket
.
Conn
nlpWsConn
,
err
=
speechNluWs
.
SpeechWs
(
reqStruct
.
MacVoice
)
nlpWsConn
,
err
=
speechNluWs
.
SpeechWs
(
reqStruct
.
MacVoice
,
reqStruct
.
Ip
)
if
err
!=
nil
{
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
reqStruct
.
RequestId
,
"requestId"
:
reqStruct
.
RequestId
,
...
...
service/speechNlu/speechWs.go
View file @
614196cc
...
@@ -20,7 +20,7 @@ type SpeechNlpWs struct {
...
@@ -20,7 +20,7 @@ type SpeechNlpWs struct {
mutex
sync
.
Mutex
mutex
sync
.
Mutex
}
}
func
(
s
*
SpeechNlpWs
)
SpeechWs
(
mac
string
)
(
*
websocket
.
Conn
,
error
)
{
func
(
s
*
SpeechNlpWs
)
SpeechWs
(
mac
,
ip
string
)
(
*
websocket
.
Conn
,
error
)
{
SpeechWs_Url
:=
global
.
SpeechSetting
.
Url
SpeechWs_Url
:=
global
.
SpeechSetting
.
Url
SpeechWs_ProductId
:=
global
.
SpeechSetting
.
ProductId
SpeechWs_ProductId
:=
global
.
SpeechSetting
.
ProductId
SpeechWs_ApiKey
:=
global
.
SpeechSetting
.
ApiKey
SpeechWs_ApiKey
:=
global
.
SpeechSetting
.
ApiKey
...
@@ -33,6 +33,8 @@ func (s *SpeechNlpWs) SpeechWs(mac string) (*websocket.Conn, error) {
...
@@ -33,6 +33,8 @@ func (s *SpeechNlpWs) SpeechWs(mac string) (*websocket.Conn, error) {
deviceId
:=
util
.
ComputerMd5
(
mac
)
deviceId
:=
util
.
ComputerMd5
(
mac
)
header
:=
http
.
Header
{}
header
:=
http
.
Header
{}
header
.
Set
(
"X-Forwarded-For"
,
ip
)
SpeechUrl
:=
SpeechWs_Url
+
"?serviceType=websocket&productId="
+
SpeechWs_ProductId
+
SpeechUrl
:=
SpeechWs_Url
+
"?serviceType=websocket&productId="
+
SpeechWs_ProductId
+
"&apikey="
+
SpeechWs_ApiKey
+
"&deviceId="
+
deviceId
"&apikey="
+
SpeechWs_ApiKey
+
"&deviceId="
+
deviceId
...
...
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