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