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
3950e916
Commit
3950e916
authored
May 14, 2025
by
赵文静
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充闹钟
parent
c60c5dfb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
256 additions
and
244 deletions
+256
-244
model/speech.go
model/speech.go
+2
-0
pkg/proto/alarm_remind_skill.pb.go
pkg/proto/alarm_remind_skill.pb.go
+106
-201
pkg/proto/alarm_remind_skill.proto
pkg/proto/alarm_remind_skill.proto
+10
-16
service/connect/alarm.go
service/connect/alarm.go
+65
-0
service/connect/music.go
service/connect/music.go
+6
-1
service/speechNlu/domain.go
service/speechNlu/domain.go
+67
-26
No files found.
model/speech.go
View file @
3950e916
...
...
@@ -77,6 +77,8 @@ type SpeechWsResp struct {
Param
*
struct
{
Volume
string
`json:"volume"`
Mode
string
`json:"mode"`
Object
string
`json:"object"`
Extra
string
`json:"extra"`
}
`json:"param"`
Api
string
`json:"api"`
}
`json:"command"`
...
...
pkg/proto/alarm_remind_skill.pb.go
View file @
3950e916
This diff is collapsed.
Click to expand it.
pkg/proto/alarm_remind_skill.proto
View file @
3950e916
...
...
@@ -10,29 +10,23 @@ message AlarmRemindSkillRequest{
string
appId
=
1
;
string
requestId
=
2
;
}
message
UserInfo
{
string
uid
=
1
;
string
hid
=
2
;
}
message
DevInfo
{
string
mac
=
1
;
string
tarMac
=
2
;
string
mid
=
2
;
string
vender
=
3
;
string
hid
=
4
;
// 模组id
string
homeId
=
5
;
//家庭id
string
uid
=
6
;
// 用户id(可以空,语音入口一般无法识别用户)
}
AppInfo
appInfo
=
1
;
DevInfo
devInfo
=
2
;
UserInfo
userInfo
=
3
;
message
Command
{
string
api
=
1
;
string
repeat
=
2
;
int64
timestamp
=
3
;
string
date
=
4
;
string
time
=
5
;
string
event
=
6
;
string
period
=
7
;
string
object
=
8
;
// 区分品类,闹钟/日程(提醒)
string
api
=
1
;
// 意图
string
extra
=
2
;
// speech解析原字段 : 内部有content字段提取闹钟列表
string
object
=
3
;
// speech解析原字段:闹钟/提醒(日程)
}
Command
command
=
4
;
string
asr_recognize
=
5
;
Command
command
=
3
;
string
asr_recognize
=
4
;
}
message
AlarmRemindSkillResponse
{
...
...
service/connect/alarm.go
0 → 100644
View file @
3950e916
package
connect
import
(
"context"
"speech-nlu-parse/global"
"speech-nlu-parse/model"
"speech-nlu-parse/pkg/logger"
"speech-nlu-parse/pkg/proto"
"time"
)
const
(
Alarm
=
"alarm_remind"
)
func
AlarmGrpc
(
params
*
model
.
SpeechDomainParams
,
api
,
extra
,
object
string
)
(
*
proto
.
AlarmRemindSkillResponse
,
error
)
{
conn
,
err
:=
GrpcConn
(
Alarm
)
if
err
!=
nil
{
global
.
Logger
.
Errorf
(
"faild to connect: %v"
,
err
)
return
nil
,
err
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
2
)
defer
cancel
()
c
:=
proto
.
NewAlarmRemindSkillClient
(
conn
)
req
:=
&
proto
.
AlarmRemindSkillRequest
{
AppInfo
:
&
proto
.
AlarmRemindSkillRequest_AppInfo
{
AppId
:
"speech-nlu-parse"
,
RequestId
:
params
.
RequestId
,
},
DevInfo
:
&
proto
.
AlarmRemindSkillRequest_DevInfo
{
Mac
:
params
.
Mac
,
Mid
:
params
.
Mid
,
Vender
:
params
.
MidType
,
Hid
:
""
,
HomeId
:
""
,
Uid
:
""
,
},
Command
:
&
proto
.
AlarmRemindSkillRequest_Command
{
Api
:
api
,
Extra
:
extra
,
Object
:
object
,
},
AsrRecognize
:
params
.
Query
,
}
resp
,
err
:=
c
.
HandleSpeechCommand
(
ctx
,
req
)
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"AlarmGrpc serverName"
:
Alarm
,
"AlarmGrpc request"
:
req
,
})
.
Errorf
(
"alarm grpc error: %v"
,
err
)
return
nil
,
err
}
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"AlarmGrpc serverName"
:
Alarm
,
"AlarmGrpc request"
:
req
,
"AlarmGrpc response"
:
resp
,
})
.
Info
(
"AlarmGrpc"
)
return
resp
,
nil
}
service/connect/music.go
View file @
3950e916
...
...
@@ -45,10 +45,15 @@ func MusicGrpc(params *model.SpeechDomainParams) (*proto.MusicSpotResponse, erro
resp
,
err
:=
c
.
GetMusicList
(
ctx
,
req
)
if
err
!=
nil
{
global
.
Logger
.
Errorf
(
"MusicGrpc error: %v"
,
err
)
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"MusicGrpc serverName"
:
MusicSpot
,
"MusicGrpc request"
:
req
,
})
.
Errorf
(
"MusicGrpc error: %v"
,
err
)
return
nil
,
err
}
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"MusicGrpc serverName"
:
MusicSpot
,
"MusicGrpc request"
:
req
,
"MusicGrpc response"
:
resp
,
...
...
service/speechNlu/domain.go
View file @
3950e916
...
...
@@ -359,33 +359,74 @@ func translateDomain(params *model.SpeechDomainParams) []byte {
return
Marshal
(
params
,
res
)
}
func
alarmDevFilter
(
params
*
model
.
SpeechDomainParams
)
bool
{
if
params
.
Mid
==
"10f05"
&&
params
.
MidType
==
"87654321"
{
return
true
}
else
if
params
.
Mid
==
"10f05"
&&
params
.
MidType
==
"7e000024"
&&
params
.
AppKey
==
"a8814080829e11eda5c8e38bb1008e50"
{
return
true
func
alarmDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
if
!
params
.
CheckDm
()
||
!
params
.
CheckCommandParam
()
{
return
replyWithChat
(
error_reply
,
"doudi"
)
}
return
false
}
var
result
model
.
ResponseBody
api
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Api
extra
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Extra
object
:=
params
.
SpeechWsResp
.
Dm
.
Command
.
Param
.
Object
type
AlarmItem
struct
{
Content
string
`json:"content"`
Id
string
`json:"id"`
Note
string
`json:"note"`
RepeatType
int
`json:"repeatType"`
SpeechType
int
`json:"speechType"`
Start
string
`json:"start"`
Type
int
`json:"type"`
Url
string
`json:"url"`
}
if
object
==
"闹钟"
{
result
.
Header
.
Semantic
.
Domain
=
"alarm"
}
else
{
result
.
Header
.
Semantic
.
Domain
=
"reminder_v2"
}
result
.
Header
.
Semantic
.
Code
=
0
result
.
Header
.
Semantic
.
Msg
=
speech_nlu_parse
result
.
AsrRecongize
=
params
.
SpeechWsResp
.
Dm
.
Input
result
.
Header
.
Semantic
.
SessionComplete
=
params
.
SpeechWsResp
.
Dm
.
ShouldEndSession
//params.SpeechWsResp.Dm.ShouldEndSession
result
.
ResponseText
=
params
.
SpeechWsResp
.
Dm
.
Nlg
if
api
==
"ai.dui.dskdm.reminder.query"
{
result
.
Header
.
Semantic
.
Intent
=
"check"
result
.
Header
.
Semantic
.
SkillId
=
result
.
Header
.
Semantic
.
Domain
+
"."
+
result
.
Header
.
Semantic
.
Intent
}
else
if
api
==
"ai.dui.dskdm.reminder.insert"
{
result
.
Header
.
Semantic
.
Intent
=
"new"
result
.
Header
.
Semantic
.
SkillId
=
result
.
Header
.
Semantic
.
Domain
+
"."
+
result
.
Header
.
Semantic
.
Intent
resAlarm
,
err
:=
connect
.
AlarmGrpc
(
params
,
api
,
extra
,
object
)
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"mac"
:
params
.
Mac
,
"mid"
:
params
.
Mid
,
"vender"
:
params
.
MidType
,
})
.
Errorf
(
"connect.AlarmGrpc error:%v"
,
err
)
return
replyWithChat
(
error_reply
,
"doudi"
)
}
if
resAlarm
.
GetStatus
()
.
GetCode
()
==
0
{
return
Marshal
(
params
,
&
result
)
}
else
{
resultTextStr
:=
"网络不稳定,请稍后再试"
return
replyWithChat
(
resultTextStr
,
"chat.chat"
)
}
}
else
if
api
==
"ai.dui.dskdm.reminder.remove"
{
result
.
Header
.
Semantic
.
Intent
=
"delete"
result
.
Header
.
Semantic
.
SkillId
=
result
.
Header
.
Semantic
.
Domain
+
"."
+
result
.
Header
.
Semantic
.
Intent
if
!
params
.
SpeechWsResp
.
Dm
.
ShouldEndSession
{
return
Marshal
(
params
,
&
result
)
}
resAlarm
,
err
:=
connect
.
AlarmGrpc
(
params
,
api
,
extra
,
object
)
if
err
!=
nil
{
global
.
Logger
.
WithFields
(
logger
.
Fields
{
"requestId"
:
params
.
RequestId
,
"mac"
:
params
.
Mac
,
"mid"
:
params
.
Mid
,
"vender"
:
params
.
MidType
,
})
.
Errorf
(
"connect.AlarmGrpc error:%v"
,
err
)
return
replyWithChat
(
error_reply
,
"doudi"
)
}
if
resAlarm
.
GetStatus
()
.
GetCode
()
==
0
{
return
Marshal
(
params
,
&
result
)
}
else
{
resultTextStr
:=
"网络不稳定,请稍后再试"
return
replyWithChat
(
resultTextStr
,
"chat.chat"
)
}
}
// 闹钟待写
func
alarmDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
//mac := params.Mac
//
//if !params.CheckDm() || !params.CheckDmParam() {
// return replyWithChat(error_reply, "doudi")
//}
//
//var result model.ResponseBody
//result.Header.Semantic.Code = 0
...
...
@@ -480,8 +521,8 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
//}
//
//return Marshal(params, &result)
resultTextStr
:=
"暂不支持闹钟设定"
return
replyWithChat
(
resultTextStr
,
"chat.chat"
)
return
Marshal
(
params
,
&
result
)
}
func
scienceDomain
(
params
*
model
.
SpeechDomainParams
)
[]
byte
{
...
...
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