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
6b3c9f37
Commit
6b3c9f37
authored
Apr 14, 2024
by
邹绪超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完成系统打断
parent
51f02bbb
Pipeline
#87245
waiting for manual action with stages
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
37 deletions
+18
-37
index.jsx
src/components/SoundAi/Ui/Dialog/index.jsx
+11
-34
index.js
...nents/SoundAi/core/core/SpeechSynthesisUtterance/index.js
+3
-0
CloseSessionDirective.js
...omponents/SoundAi/core/directive/CloseSessionDirective.js
+1
-1
SparkDirective.js
src/components/SoundAi/core/directive/SparkDirective.js
+2
-1
TestDirective.js
src/components/SoundAi/core/directive/TestDirective.js
+1
-1
No files found.
src/components/SoundAi/Ui/Dialog/index.jsx
View file @
6b3c9f37
...
...
@@ -69,15 +69,10 @@ const Dialog = props => {
const
finish
=
useCallback
(
async
({
resultText
})
=>
{
if
(
!
resultText
)
return
pandaSpeechSynthesisUtteranceRef
.
current
?.
clear
()
if
(
pandaRecordWebSocketRef
.
current
)
{
if
(
isOpenSystemSound
)
{
pandaRecordWebSocketRef
.
current
.
stopRecorderManager
()
}
// else {
// pandaRecordWebSocketRef.current.setStatus("pause")
// }
if
(
currentDirectiveRef
.
current
)
{
return
}
pandaSpeechSynthesisUtteranceRef
.
current
?.
clear
()
const
directive
=
directiveRef
.
current
.
parse
({
text
:
resultText
})
...
...
@@ -102,14 +97,6 @@ const Dialog = props => {
await
pandaSpeechSynthesisUtteranceRef
.
current
.
speakEnd
()
startTime
()
}
if
(
pandaRecordWebSocketRef
.
current
)
{
if
(
isOpenSystemSound
)
{
pandaRecordWebSocketRef
.
current
.
resumeRecorderManager
()
}
// else {
// pandaRecordWebSocketRef.current.setStatus("playing")
// }
}
currentDirectiveRef
.
current
=
null
return
}
...
...
@@ -122,38 +109,32 @@ const Dialog = props => {
pandaSpeechSynthesisUtteranceRef
.
current
.
push
(
defaultEmptyMsg
)
await
pandaSpeechSynthesisUtteranceRef
.
current
.
speakEnd
()
}
if
(
pandaRecordWebSocketRef
.
current
)
{
if
(
isOpenSystemSound
)
{
pandaRecordWebSocketRef
.
current
.
resumeRecorderManager
()
}
// else {
// pandaRecordWebSocketRef.current.setStatus("playing")
// }
}
},
[])
const
frame
=
useCallback
((
data
)
=>
{
const
{
resultText
,
resultTextTemp
}
=
data
console
.
log
(
resultTextTemp
)
if
(
!
resultTextTemp
)
return
const
hasCloseSessionDirective
=
closeDirectiveRef
.
current
.
parse
({
text
:
resultTextTemp
})
!
currentDirectiveRef
.
current
&&
updateUserData
({
resultTextTemp
})
if
(
hasCloseSessionDirective
)
{
closeSession
({
resultText
:
resultTextTemp
})
}
else
{
!
currentDirectiveRef
.
current
&&
updateUserData
({
resultTextTemp
})
}
},
[])
const
closeSession
=
({
resultText
})
=>
{
if
(
currentDirectiveRef
.
current
)
{
currentDirectiveRef
.
current
.
closeResponse
()
delayStartSocket
()
pandaSpeechSynthesisUtteranceRef
.
current
?.
clear
()
closeSessionReocrder
()
currentDirectiveRef
.
current
=
null
}
else
{
if
(
!
isDebug
)
{
delayStartSocket
()
closeSessionReocrder
()
event
.
emit
(
"aiSound:finish"
,
{
resultText
})
...
...
@@ -161,12 +142,8 @@ const Dialog = props => {
}
}
const
delayStartSocket
=
()
=>
{
pandaRecordWebSocketRef
.
current
.
wsClose
()
pandaRecordWebSocketRef
.
current
.
setStatus
(
"pause"
)
setTimeout
(()
=>
{
pandaRecordWebSocketRef
.
current
.
setStatus
(
"playing"
)
},
500
)
const
closeSessionReocrder
=
()
=>
{
pandaRecordWebSocketRef
.
current
?.
wsClose
?.()
}
const
updateUserData
=
({
resultTextTemp
})
=>
{
...
...
src/components/SoundAi/core/core/SpeechSynthesisUtterance/index.js
View file @
6b3c9f37
...
...
@@ -68,6 +68,9 @@ class PandaSpeechSynthesisUtterance {
clear
()
{
this
.
data
=
[]
window
.
speechSynthesis
.
cancel
()
if
(
this
.
resolve
)
{
this
.
resolve
()
}
}
}
...
...
src/components/SoundAi/core/directive/CloseSessionDirective.js
View file @
6b3c9f37
...
...
@@ -3,7 +3,7 @@ import BaseDirective from './BaseDirective'
class
CloseSessionDirective
extends
BaseDirective
{
match
(){
const
{
text
}
=
this
if
(
/
[
熊猫熊猫|什么什么
]
/
.
test
(
text
))
{
if
(
/
(
熊猫熊猫
)
|
(
什么什么
)
/
.
test
(
text
))
{
return
true
}
return
false
...
...
src/components/SoundAi/core/directive/SparkDirective.js
View file @
6b3c9f37
...
...
@@ -18,6 +18,7 @@ class SparkDirective extends BaseDirective {
sendMsg
=
function
()
{}
})
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
this
.
reject
=
reject
this
.
resolve
=
resolve
this
.
sendMsg
=
sendMsg
const
data
=
await
this
.
pandaSparkWebSocket
.
sendMessag
({
...
...
@@ -35,8 +36,8 @@ class SparkDirective extends BaseDirective {
if
(
this
.
pandaSparkWebSocket
)
{
this
.
pandaSparkWebSocket
.
stop
()
}
this
.
resolve
(
""
)
this
.
sendMsg
=
null
this
.
reject
(
""
)
}
destroy
(){
...
...
src/components/SoundAi/core/directive/TestDirective.js
View file @
6b3c9f37
...
...
@@ -23,7 +23,7 @@ class TestDirective extends BaseDirective {
clearInterval
(
this
.
timer
)
this
.
timer
=
null
}
this
.
re
solve
&&
this
.
resolve
()
this
.
re
ject
&&
this
.
reject
()
}
testCloseSession
({
sendMsg
})
{
...
...
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