Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
32ff219e
Commit
32ff219e
authored
Mar 07, 2024
by
xuchaozou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peraf: 优化语音逻辑
parent
a32c8fae
Pipeline
#85758
passed with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
14 deletions
+66
-14
PandaUi.js
src/components/SoundAi/PandaUi.js
+14
-0
style.less
src/components/SoundAi/Ui/PandaTip/style.less
+1
-1
PandaRecordWebSocket.js
...ponents/SoundAi/core/core/sockets/PandaRecordWebSocket.js
+9
-1
ByeDirective.js
src/components/SoundAi/core/directive/ByeDirective.js
+1
-1
CloseMenuDirective.js
src/components/SoundAi/core/directive/CloseMenuDirective.js
+36
-3
OpenMenuDirective.js
src/components/SoundAi/core/directive/OpenMenuDirective.js
+5
-5
index.js
src/components/SoundAi/index.js
+0
-3
No files found.
src/components/SoundAi/PandaUi.js
View file @
32ff219e
...
...
@@ -67,9 +67,23 @@ const PandaUi = props => {
},
finish
(
data
)
{
event
.
emit
(
"aiSound:finish"
,
data
)
},
fail
({
data
})
{
message
.
info
(
data
.
msg
)
console
.
log
(
data
)
emitSwitch
({
loading
:
false
,
checked
:
false
})
}
}
})
// await testText("请打开泵站。")
// await testText("第2个")
// await testText("请打开泵站。")
// await testText("第3个")
// await testText("关闭泵站。");
// await testText("第二个");
// await testText("我需要打开浩源孪生平台菜单")
// await testText("我需要返回首页")
// await testText("我需要打开礼泉孪生平台菜单")
...
...
src/components/SoundAi/Ui/PandaTip/style.less
View file @
32ff219e
...
...
@@ -2,7 +2,7 @@
position: absolute;
right: 50px;
bottom: 50px;
z-index:
100
;
z-index:
9999
;
.image{
width: 80px;
height: 80px;
...
...
src/components/SoundAi/core/core/sockets/PandaRecordWebSocket.js
View file @
32ff219e
...
...
@@ -216,6 +216,7 @@ class PandaRecordWebSocket extends PandaWebSocket {
}
// 开启wpgs会有此字段(前提:在控制台开通动态修正功能)
// 取值为 "apd"时表示该片结果是追加到前面的最终结果;取值为"rpl" 时表示替换前面的部分结果,替换范围为rg字段
if
(
data
.
pgs
)
{
if
(
data
.
pgs
===
'apd'
)
{
// 将resultTextTemp同步给resultText
...
...
@@ -226,6 +227,9 @@ class PandaRecordWebSocket extends PandaWebSocket {
}
else
{
this
.
resultText
=
this
.
resultText
+
str
;
}
if
(
!
this
.
resultTextTemp
)
{
return
}
this
.
events
.
frame
({
resultTextTemp
:
this
.
resultTextTemp
,
resultText
:
this
.
resultText
,
...
...
@@ -234,8 +238,10 @@ class PandaRecordWebSocket extends PandaWebSocket {
});
}
if
(
jsonData
.
code
==
0
&&
jsonData
.
data
.
status
==
2
)
{
const
resultText
=
this
.
resultTextTemp
?
this
.
resultTextTemp
:
this
.
resultText
if
(
!
resultText
)
return
this
.
events
.
finish
({
resultText
:
this
.
resultTextTemp
?
this
.
resultTextTemp
:
this
.
resultText
,
resultText
,
});
this
.
reconnect
();
}
...
...
@@ -245,8 +251,10 @@ class PandaRecordWebSocket extends PandaWebSocket {
msg
:
FAIL_TYPE_DATA_ERRRO_MSG
,
data
:
{
code
:
jsonData
.
code
,
msg
:
jsonData
.
message
},
});
console
.
log
(
jsonData
)
this
.
destroy
();
}
}
...
...
src/components/SoundAi/core/directive/ByeDirective.js
View file @
32ff219e
...
...
@@ -3,7 +3,7 @@ import BaseDirective from "./BaseDirective";
class
ByeDirective
extends
BaseDirective
{
match
()
{
const
{
text
}
=
this
if
(
/再见|拜拜|关闭/
.
test
(
text
))
{
if
(
/再见|拜拜|关闭
熊猫
/
.
test
(
text
))
{
return
true
}
return
false
...
...
src/components/SoundAi/core/directive/CloseMenuDirective.js
View file @
32ff219e
import
BaseDirective
from
"./BaseDirective"
;
import
{
store
,
event
}
from
'@wisdom-utils/utils'
import
Utils
from
"../utils/Utils"
;
class
CloseMenuDirective
extends
BaseDirective
{
match
()
{
const
{
text
}
=
this
let
result
=
null
if
(
this
.
getBeforeLastGroupDirective
())
{
result
=
text
.
match
(
/第
([
一|二|三|四|五|六|七|八|九|十
]
+
)
个/
)
if
(
result
&&
result
.
length
>=
2
)
{
this
.
matchResult
=
Utils
.
chineseToNumber
(
result
[
1
])
}
else
if
(
!
result
)
{
result
=
text
.
match
(
/第
[\u
4e00-
\u
9fa5
]?(\d
+
)
个/
)
if
(
result
&&
result
.
length
>=
2
)
{
this
.
matchResult
=
Number
(
result
[
1
])
}
}
}
result
=
text
.
match
(
/关闭
(
.*
)(?=(?:
菜单|功能|路径
))
/
)
if
(
!
result
)
{
result
=
text
.
match
(
/关闭
(
.*
)(?=(?:
,|,|。
))
/
)
...
...
@@ -15,11 +29,30 @@ class CloseMenuDirective extends BaseDirective {
return
!!
this
.
matchResult
}
getBeforeLastGroupDirective
()
{
const
lastMenu
=
this
.
directives
.
at
(
-
1
)
if
(
!
lastMenu
)
return
false
if
(
!
(
lastMenu
instanceof
CloseMenuDirective
)
)
return
false
if
(
!
lastMenu
.
data
||
lastMenu
.
data
.
type
!=
"widgets"
||
lastMenu
.
data
.
widgets
.
length
==
0
)
return
false
return
true
}
async
excute
()
{
let
widgets
=
null
if
(
this
.
data
)
{
}
else
{
if
(
typeof
this
.
matchResult
==
"number"
)
{
const
widgets
=
this
.
getOpenedMenus
()
if
(
this
.
matchResult
==
0
||
this
.
matchResult
>
widgets
.
length
)
{
this
.
data
=
{}
this
.
data
.
type
=
"widgets"
this
.
data
.
widgets
=
widgets
return
`索引超出了界限,请重新语音选择关闭第几个菜单`
}
else
{
const
menu
=
widgets
[
this
.
matchResult
]
event
.
emit
(
"event:closeMenuByName"
,
menu
.
name
)
return
`关闭
${
menu
.
name
}
菜单成功`
}
}
else
{
widgets
=
this
.
getIsOneWdiget
()
if
(
!
widgets
)
{
widgets
=
this
.
getCompleteMenus
()
...
...
src/components/SoundAi/core/directive/OpenMenuDirective.js
View file @
32ff219e
...
...
@@ -8,11 +8,11 @@ class OpenMenuDirective extends BaseDirective {
const
{
text
}
=
this
let
result
=
null
if
(
this
.
getBeforeLastGroupDirective
())
{
result
=
text
.
match
(
/
打开.*
([
一|二|三|四|五|六|七|八|九|十
]
+
)
/
)
result
=
text
.
match
(
/
第
([
一|二|三|四|五|六|七|八|九|十
]
+
)
个
/
)
if
(
result
&&
result
.
length
>=
2
)
{
this
.
matchResult
=
Utils
.
chineseToNumber
(
result
[
1
])
}
else
if
(
!
result
)
{
result
=
text
.
match
(
/
打开
[\u
4e00-
\u
9fa5
]?(\d
+
)
/
)
result
=
text
.
match
(
/
第
[\u
4e00-
\u
9fa5
]?(\d
+
)
个
/
)
if
(
result
&&
result
.
length
>=
2
)
{
this
.
matchResult
=
Number
(
result
[
1
])
}
...
...
@@ -22,7 +22,7 @@ class OpenMenuDirective extends BaseDirective {
result
=
text
.
match
(
/打开
(
.*
)(?=(?:
菜单|功能|路径
))
/
)
}
if
(
!
result
)
{
result
=
text
.
match
(
/打开
(
.*
)(?=(?:
,|,|。
|
))
/
)
result
=
text
.
match
(
/打开
(
.*
)(?=(?:
,|,|。
))
/
)
}
if
(
result
&&
result
.
length
>=
2
&&
!
this
.
matchResult
)
{
this
.
matchResult
=
result
[
1
]
...
...
@@ -33,7 +33,7 @@ class OpenMenuDirective extends BaseDirective {
getBeforeLastGroupDirective
()
{
const
lastMenu
=
this
.
directives
.
at
(
-
1
)
if
(
!
lastMenu
)
return
false
if
(
!
lastMenu
instanceof
OpenMenuDirective
)
return
false
if
(
!
(
lastMenu
instanceof
OpenMenuDirective
)
)
return
false
if
(
!
lastMenu
.
data
||
lastMenu
.
data
.
type
!=
"widgets"
||
lastMenu
.
data
.
widgets
.
length
==
0
)
return
false
return
true
}
...
...
@@ -86,7 +86,7 @@ class OpenMenuDirective extends BaseDirective {
}
widgetsToMsg
(
widgets
)
{
return
`有以下
${
widgets
.
length
}
个菜单\n
${
widgets
.
map
((
widget
,
index
)
=>
`
${
index
+
1
}
.
${
widget
.
label
}
`
).
join
(
"
\
n"
)}
,
\n请语音确认一下打开第几个菜单`
return
`有以下
${
widgets
.
length
}
个菜单\n
${
widgets
.
map
((
widget
,
index
)
=>
`
${
index
+
1
}
.
${
widget
.
label
}
`
).
join
(
"
\
n"
)}
\n请语音确认一下打开第几个菜单`
}
getCompleteMenus
()
{
...
...
src/components/SoundAi/index.js
View file @
32ff219e
...
...
@@ -11,9 +11,6 @@ const SoundAi = props => {
try
{
await
getIsOpenConfig
()
await
getKey
()
event
.
emit
(
"record:changeVisible"
,
{
visible
:
true
})
setVisible
(
true
)
}
catch
(
error
)
{
console
.
warn
(
error
)
...
...
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