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
f4892c4d
You need to sign in or sign up before continuing.
Commit
f4892c4d
authored
Dec 05, 2023
by
ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化打包路径问题
parent
7456d071
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
68 deletions
+60
-68
PhotoScreen.vue
src/renderer/screens/PhotoScreen.vue
+7
-2
ShowPhoto.vue
src/renderer/screens/ShowPhoto.vue
+21
-22
ShowVideo.vue
src/renderer/screens/ShowVideo.vue
+3
-13
VideoScreen.vue
src/renderer/screens/VideoScreen.vue
+1
-1
photo.ts
src/renderer/store/photo.ts
+2
-2
settings.ts
src/renderer/store/settings.ts
+15
-17
video.ts
src/renderer/store/video.ts
+11
-11
No files found.
src/renderer/screens/PhotoScreen.vue
View file @
f4892c4d
...
...
@@ -7,7 +7,12 @@ import { storeToRefs } from 'pinia'
const
{
photo
:
usePhoto
,
settings
}
=
useStore
()
const
photo
=
storeToRefs
(
usePhoto
)
onMounted
(():
void
=>
{})
onMounted
(():
void
=>
{
console
.
log
(
'---------------->'
,
new
URL
(
'/vosk/models/vosk-model-small-cn-0.3.tar.gz'
,
import
.
meta
.
url
)
)
})
async
function
handleOpen
(
event
:
Event
,
url
:
string
)
{
const
img
=
event
.
target
as
HTMLImageElement
...
...
@@ -83,7 +88,7 @@ function removePhoto(index: number) {
:width=
"200"
aspect-ratio=
"1/1"
cover
:src=
"
settings.filePath + './..' +
item.url"
:src=
"item.url"
@
click=
"handleOpen($event, item.url)"
></v-img>
<v-btn
...
...
src/renderer/screens/ShowPhoto.vue
View file @
f4892c4d
...
...
@@ -15,6 +15,7 @@ const router = useRouter()
const
route
=
useRoute
()
const
{
settings
}
=
useStore
()
const
sampleRate
=
48000
const
iconMicrophone
=
new
URL
(
'/images/microphone-input.svg'
,
import
.
meta
.
url
).
href
const
recordVolume
=
ref
(
0
)
const
url
=
route
.
query
.
url
as
string
...
...
@@ -29,7 +30,7 @@ onMounted(() => {
function
loadImg
():
Promise
<
HTMLImageElement
>
{
const
img
=
new
Image
()
img
.
src
=
settings
.
filePath
+
'./..'
+
url
img
.
src
=
url
return
new
Promise
((
resolve
,
reject
)
=>
{
img
.
onload
=
()
=>
resolve
(
img
)
img
.
onerror
=
reject
...
...
@@ -247,8 +248,8 @@ function endAudioInput() {
}
async
function
onAsr
(
question
:
string
)
{
console
.
log
(
'---------------->question: '
,
question
)
;
endAudioInput
()
;
console
.
log
(
'---------------->question: '
,
question
)
endAudioInput
()
const
ws
=
await
initSocket
()
inputContext
.
ws
=
ws
...
...
@@ -315,16 +316,20 @@ async function runTTSTask(tasks: string[]) {
while
(
tasks
.
length
)
{
const
task
=
tasks
.
shift
()
if
(
!
task
)
break
if
(
task
.
length
<
1
)
continue
;
if
(
task
.
length
<
1
)
continue
console
.
time
(
task
+
' TTS: '
)
const
res
=
await
localTTS
({
url
:
settings
.
ttsHost
,
text
:
task
,
audio_path
:
settings
.
userData
})
const
res
=
await
localTTS
({
url
:
settings
.
ttsHost
,
text
:
task
,
audio_path
:
settings
.
userData
})
console
.
log
(
'----------------> TTS:'
,
res
[
0
].
text
)
console
.
timeEnd
(
task
+
' TTS: '
)
const
audio
=
new
Audio
(
`file://
${
res
[
0
].
text
}
`
)
;
audio
.
load
()
;
ttsAudios
.
push
(
audio
)
;
runAudioPlay
()
;
const
audio
=
new
Audio
(
`file://
${
res
[
0
].
text
}
`
)
audio
.
load
()
ttsAudios
.
push
(
audio
)
runAudioPlay
()
}
}
catch
(
error
)
{
console
.
error
(
error
)
...
...
@@ -339,16 +344,16 @@ async function runAudioPlay() {
if
(
isPlayRunning
)
return
isPlayRunning
=
true
const
audio
=
ttsAudios
.
shift
()
;
const
audio
=
ttsAudios
.
shift
()
if
(
!
audio
)
{
isPlayRunning
=
false
;
return
;
isPlayRunning
=
false
return
}
audio
.
onended
=
()
=>
{
isPlayRunning
=
false
;
isPlayRunning
=
false
runAudioPlay
()
}
;
await
audio
.
play
()
;
}
await
audio
.
play
()
}
// eslint-disable-next-line no-unused-vars
...
...
@@ -396,13 +401,7 @@ async function xfTTS(text: string) {
<v-icon
v-if=
"microphoneState === 'disabled'"
icon=
"mdi-microphone-off"
></v-icon>
<template
v-if=
"microphoneState === 'input'"
>
<img
width=
"30"
height=
"30"
:src=
"settings.filePath + './..' + '/images/microphone-input.svg'"
alt=
""
srcset=
""
/>
<img
width=
"30"
height=
"30"
:src=
"iconMicrophone"
alt=
""
srcset=
""
/>
<div
class=
"progress"
>
<span
class=
"volume"
...
...
src/renderer/screens/ShowVideo.vue
View file @
f4892c4d
...
...
@@ -15,6 +15,7 @@ const router = useRouter()
const
route
=
useRoute
()
const
{
settings
,
video
:
useVideo
}
=
useStore
()
const
sampleRate
=
48000
const
iconMicrophone
=
new
URL
(
'/images/microphone-input.svg'
,
import
.
meta
.
url
).
href
const
recordVolume
=
ref
(
0
)
const
url
=
route
.
query
.
url
as
string
...
...
@@ -229,12 +230,7 @@ async function xfTTS(text: string) {
class=
"d-flex justify-center align-center"
:style=
"
{ background: '#000' }"
>
<video
id=
"videoElement"
ref=
"videoElement"
:src=
"settings.filePath + './..' + url"
class=
"video-ele"
></video>
<video
id=
"videoElement"
ref=
"videoElement"
:src=
"url"
class=
"video-ele"
></video>
</div>
<div
class=
"voice"
>
...
...
@@ -251,13 +247,7 @@ async function xfTTS(text: string) {
<v-icon
v-if=
"microphoneState === 'disabled'"
icon=
"mdi-microphone-off"
></v-icon>
<template
v-if=
"microphoneState === 'input'"
>
<img
width=
"30"
height=
"30"
:src=
"settings.filePath + './..' + '/images/microphone-input.svg'"
alt=
""
srcset=
""
/>
<img
width=
"30"
height=
"30"
:src=
"iconMicrophone"
alt=
""
srcset=
""
/>
<div
class=
"progress"
>
<span
class=
"volume"
...
...
src/renderer/screens/VideoScreen.vue
View file @
f4892c4d
...
...
@@ -90,7 +90,7 @@ function handleLeave(e: Event) {
<video
class=
"video-item"
loop
:src=
"
settings.filePath + './..' +
item.url"
:src=
"item.url"
muted
@
click=
"handleOpen($event, item.url)"
@
pointerenter=
"handleEnter"
...
...
src/renderer/store/photo.ts
View file @
f4892c4d
...
...
@@ -10,10 +10,10 @@ const usePhotoStore = defineStore('photo', {
({
list
:
[
{
url
:
'/2023-11-2/93ffb6a7-ae93-4918-944e-877016ba266b.png'
url
:
new
URL
(
'/2023-11-2/93ffb6a7-ae93-4918-944e-877016ba266b.png'
,
import
.
meta
.
url
).
href
},
{
url
:
'/2023-11-2/6fa9a127-2ce5-43ea-a543-475bf9354eda.png'
url
:
new
URL
(
'/2023-11-2/6fa9a127-2ce5-43ea-a543-475bf9354eda.png'
,
import
.
meta
.
url
).
href
}
]
})
as
IPhoto
,
...
...
src/renderer/store/settings.ts
View file @
f4892c4d
...
...
@@ -37,21 +37,21 @@ const useSettingsStore = defineStore('settings', {
asr
:
'vosk_asr'
,
tts
:
'local_tts'
,
voskModels
:
[
'vosk-model-small-ca-0.4.tar.gz'
,
'vosk-model-small-cn-0.3.tar.gz'
,
'vosk-model-small-de-0.15.tar.gz'
,
'vosk-model-small-en-in-0.4.tar.gz'
,
'vosk-model-small-en-us-0.15.tar.gz'
,
'vosk-model-small-es-0.3.tar.gz'
,
'vosk-model-small-fa-0.4.tar.gz'
,
'vosk-model-small-fr-pguyot-0.3.tar.gz'
,
'vosk-model-small-it-0.4.tar.gz'
,
'vosk-model-small-pt-0.3.tar.gz'
,
'vosk-model-small-ru-0.4.tar.gz'
,
'vosk-model-small-tr-0.3.tar.gz'
,
'vosk-model-small-vn-0.3.tar.gz'
new
URL
(
'/vosk/models/vosk-model-small-ca-0.4.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-cn-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-de-0.15.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-en-in-0.4.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-en-us-0.15.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-es-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-fa-0.4.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-fr-pguyot-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-it-0.4.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-pt-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-ru-0.4.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-tr-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
new
URL
(
'/vosk/models/vosk-model-small-vn-0.3.tar.gz'
,
import
.
meta
.
url
).
href
],
voskSelectModel
:
'vosk-model-small-cn-0.3.tar.gz'
,
voskSelectModel
:
new
URL
(
'/vosk/models/vosk-model-small-cn-0.3.tar.gz'
,
import
.
meta
.
url
).
href
,
ttsHost
:
'https://beta.laihua.com'
,
source
:
[],
selectSource
:
''
,
...
...
@@ -77,9 +77,7 @@ const useSettingsStore = defineStore('settings', {
return
voskModelMap
.
get
(
this
.
$state
.
voskSelectModel
)
as
Model
}
const
model
=
await
Vosk
.
createModel
(
`
${
this
.
$state
.
filePath
}
./../vosk/models/
${
this
.
$state
.
voskSelectModel
}
`
)
const
model
=
await
Vosk
.
createModel
(
this
.
$state
.
voskSelectModel
)
voskModelMap
.
set
(
this
.
$state
.
voskSelectModel
,
model
)
return
model
...
...
src/renderer/store/video.ts
View file @
f4892c4d
...
...
@@ -10,56 +10,56 @@ const useVideoStore = defineStore('video', {
({
list
:
[
{
url
:
'/libai/wait.mp4'
,
url
:
new
URL
(
'/libai/wait.mp4'
,
import
.
meta
.
url
).
href
,
name
:
'李白'
,
qa
:
[
{
url
:
'/libai/1.mp4'
,
url
:
new
URL
(
'/libai/1.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白是谁?'
,
a
:
'李白是中国唐代著名的诗人,被誉为“诗仙”。他的诗作以豪放、想象力丰富而著称。'
},
{
url
:
'/libai/2.mp4'
,
url
:
new
URL
(
'/libai/2.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白生活在哪个时期?'
,
a
:
'李白生活在唐朝,大约在公元701年到762年之间。'
},
{
url
:
'/libai/3.mp4'
,
url
:
new
URL
(
'/libai/3.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白的诗有什么特点?'
,
a
:
'李白的诗以其浪漫主义风格、对自然景观的细腻描绘和对自由无拘无束的追求而闻名。'
},
{
url
:
'/libai/4.mp4'
,
url
:
new
URL
(
'/libai/4.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白最著名的作品是哪些?'
,
a
:
' 李白最著名的作品包括《将进酒》、《庐山谣》、《静夜思》等。'
},
{
url
:
'/libai/5.mp4'
,
url
:
new
URL
(
'/libai/5.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白的诗歌反映了哪些主题?'
,
a
:
'李白的诗歌主题多样,包括对自然的赞美、对友情和饮酒的颂扬,以及对道教思想的探索。'
},
{
url
:
'/libai/6.mp4'
,
url
:
new
URL
(
'/libai/6.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白的作品在中国文学中有什么影响?'
,
a
:
'李白的作品对中国文学产生了深远的影响,他的诗歌被视为中国古典诗歌的高峰,影响了后世无数诗人。'
},
{
url
:
'/libai/7.mp4'
,
url
:
new
URL
(
'/libai/7.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白的诗歌风格与其他唐代诗人有何不同?'
,
a
:
'与其他唐代诗人相比,李白的诗歌更加注重个人情感的表达,风格更为豪放不羁。'
},
{
url
:
'/libai/8.mp4'
,
url
:
new
URL
(
'/libai/8.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白在历史上有哪些著名的轶事?'
,
a
:
'李白有许多著名轶事,例如他在月光下划船、醉酒作诗等,这些故事体现了他自由奔放的生活态度。'
},
{
url
:
'/libai/9.mp4'
,
url
:
new
URL
(
'/libai/9.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'李白的诗歌对现代文化有什么影响?'
,
a
:
'李白的诗歌对现代文化仍有深远影响,不仅在中国,也在世界各地,他的作品被翻译成多种语言,被广泛阅读和研究。'
},
{
url
:
'/libai/10.mp4'
,
url
:
new
URL
(
'/libai/10.mp4'
,
import
.
meta
.
url
).
href
,
q
:
'如何评价李白在中国文学史上的地位?'
,
a
:
'李白在中国文学史上占据着极其重要的地位,他的作品不仅丰富了诗歌的艺术表现形式,也反映了唐代社会的精神风貌。'
}
...
...
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