Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CharIP-Electron
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
ali
CharIP-Electron
Commits
19dfc9af
Commit
19dfc9af
authored
Dec 28, 2023
by
ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复相应bug
parent
38df065c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
PhotoRole.ts
src/renderer/plugins/live/PhotoRole.ts
+1
-1
ShowPhoto.vue
src/renderer/screens/ShowPhoto.vue
+5
-2
ShowVideo.vue
src/renderer/screens/ShowVideo.vue
+5
-5
No files found.
src/renderer/plugins/live/PhotoRole.ts
View file @
19dfc9af
...
@@ -351,7 +351,7 @@ export class PhotoRole extends EventEmitter {
...
@@ -351,7 +351,7 @@ export class PhotoRole extends EventEmitter {
return
new
Promise
<
boolean
>
((
resolve
)
=>
{
return
new
Promise
<
boolean
>
((
resolve
)
=>
{
let
count
=
0
let
count
=
0
const
keepCalling
=
async
()
=>
{
const
keepCalling
=
async
()
=>
{
if
(
count
>=
1
0
)
return
resolve
(
false
)
if
(
count
>=
3
0
)
return
resolve
(
false
)
count
++
count
++
const
{
status
}
=
await
this
.
_getLiveStatus
(
taskId
)
const
{
status
}
=
await
this
.
_getLiveStatus
(
taskId
)
...
...
src/renderer/screens/ShowPhoto.vue
View file @
19dfc9af
...
@@ -368,6 +368,7 @@ function initLLMSocket(): Promise<WebSocket> {
...
@@ -368,6 +368,7 @@ function initLLMSocket(): Promise<WebSocket> {
async function endAudioInput() {
async function endAudioInput() {
microphoneState.value = 'waitInput'
microphoneState.value = 'waitInput'
inputContext.ws?.close()
inputContext.mediaStream?.getTracks().forEach((track) => track.stop())
inputContext.mediaStream?.getTracks().forEach((track) => track.stop())
inputContext.audioContext?.close()
inputContext.audioContext?.close()
inputContext.audioContext2?.close()
inputContext.audioContext2?.close()
...
@@ -443,8 +444,10 @@ async function onQ(question: string) {
...
@@ -443,8 +444,10 @@ async function onQ(question: string) {
photoRole!.on('asyncAnswer', onAsyncAnswer)
photoRole!.on('asyncAnswer', onAsyncAnswer)
ws.onmessage = (message) => {
ws.onmessage = (message) => {
clearTimeout(messageTimeout)
try {
try {
cons
t { text, event } = JSON.parse(message.data) as {
le
t { text, event } = JSON.parse(message.data) as {
event: string
event: string
message_num: number
message_num: number
text: string
text: string
...
@@ -460,12 +463,12 @@ async function onQ(question: string) {
...
@@ -460,12 +463,12 @@ async function onQ(question: string) {
return
return
}
}
text = text.replace(/\u0000/g, '').trim()
answer += text
answer += text
photoRole!.answerArgs!.answer += answer
photoRole!.answerArgs!.answer += answer
photoRole!.answerArgs!._typingAnswer.push(answer)
photoRole!.answerArgs!._typingAnswer.push(answer)
isTime && console.time('sliceAnswer')
isTime && console.time('sliceAnswer')
isTime = false
isTime = false
clearTimeout(messageTimeout)
const textArr = text.split('')
const textArr = text.split('')
for (let i = 0; i < textArr.length; i++) {
for (let i = 0; i < textArr.length; i++) {
...
...
src/renderer/screens/ShowVideo.vue
View file @
19dfc9af
...
@@ -263,6 +263,7 @@ function initLLMSocket(): Promise<WebSocket> {
...
@@ -263,6 +263,7 @@ function initLLMSocket(): Promise<WebSocket> {
function
endAudioInput
()
{
function
endAudioInput
()
{
microphoneState
.
value
=
'waitInput'
microphoneState
.
value
=
'waitInput'
inputContext
.
ws
?.
close
()
inputContext
.
mediaStream
?.
getTracks
().
forEach
((
track
)
=>
track
.
stop
())
inputContext
.
mediaStream
?.
getTracks
().
forEach
((
track
)
=>
track
.
stop
())
inputContext
.
audioContext
?.
close
()
inputContext
.
audioContext
?.
close
()
inputContext
.
audioContext2
?.
close
()
inputContext
.
audioContext2
?.
close
()
...
@@ -360,12 +361,14 @@ async function onQ(question: string) {
...
@@ -360,12 +361,14 @@ async function onQ(question: string) {
let
sliceAnswerLength
=
10
let
sliceAnswerLength
=
10
inputContext
.
ws
=
ws
inputContext
.
ws
=
ws
ws
.
onmessage
=
(
message
)
=>
{
ws
.
onmessage
=
(
message
)
=>
{
clearTimeout
(
messageTimeout
)
if
(
microphoneState
.
value
===
'input'
)
{
if
(
microphoneState
.
value
===
'input'
)
{
return
return
}
}
try
{
try
{
cons
t
{
text
,
event
}
=
JSON
.
parse
(
message
.
data
)
as
{
le
t
{
text
,
event
}
=
JSON
.
parse
(
message
.
data
)
as
{
event
:
string
event
:
string
message_num
:
number
message_num
:
number
text
:
string
text
:
string
...
@@ -375,18 +378,15 @@ async function onQ(question: string) {
...
@@ -375,18 +378,15 @@ async function onQ(question: string) {
inputContext
.
answerArray
.
push
(
sliceAnswer
)
inputContext
.
answerArray
.
push
(
sliceAnswer
)
runTTSTask
()
runTTSTask
()
sliceAnswer
=
''
sliceAnswer
=
''
inputContext
.
answerArray
.
push
(
sliceAnswer
)
sliceAnswer
=
''
inputContext
.
ws
?.
close
()
inputContext
.
ws
?.
close
()
console
.
log
(
'----------------> answer: '
,
answer
)
console
.
log
(
'----------------> answer: '
,
answer
)
return
return
}
}
text
=
text
.
replace
(
/
\u
0000/g
,
''
).
trim
()
answer
+=
text
answer
+=
text
isTime
&&
console
.
time
(
'sliceAnswer'
)
isTime
&&
console
.
time
(
'sliceAnswer'
)
isTime
=
false
isTime
=
false
clearTimeout
(
messageTimeout
)
const
textArr
=
text
.
split
(
''
)
const
textArr
=
text
.
split
(
''
)
for
(
let
i
=
0
;
i
<
textArr
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
textArr
.
length
;
i
++
)
{
...
...
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