Commit 3d9e9744 authored by ali's avatar ali

feat: vosk 配置提前加载

parent 0aff8cf0
...@@ -101,6 +101,14 @@ changeVoskModel(); ...@@ -101,6 +101,14 @@ changeVoskModel();
required required
></v-select> ></v-select>
<v-select
v-model="setting.tts.value"
:items="['xf_tts', 'local_tts']"
:rules="[(v) => !!v || '请选择 TTS']"
label="文字转语音(TTS)"
required
></v-select>
<template v-if="asrSelect === 'vosk_asr'"> <template v-if="asrSelect === 'vosk_asr'">
<v-select <v-select
v-model="setting.voskSelectModel.value" v-model="setting.voskSelectModel.value"
...@@ -113,6 +121,17 @@ changeVoskModel(); ...@@ -113,6 +121,17 @@ changeVoskModel();
></v-select> ></v-select>
</template> </template>
<template v-if="setting.tts.value === 'xf_tts'">
<v-select
v-model="setting.selectSource.value"
:items="source"
:rules="[(v) => !!v || '请选择音色']"
label="TTS 音色"
required
@update:model-value="changeSource"
></v-select>
</template>
<v-text-field <v-text-field
label="TTS 域名" label="TTS 域名"
:rules="[(value) => !!value || 'TTS 域名必填']" :rules="[(value) => !!value || 'TTS 域名必填']"
...@@ -120,15 +139,6 @@ changeVoskModel(); ...@@ -120,15 +139,6 @@ changeVoskModel();
:model-value="setting.ttsHost" :model-value="setting.ttsHost"
></v-text-field> ></v-text-field>
<v-select
v-model="setting.selectSource.value"
class="mt-6"
:items="source"
:rules="[(v) => !!v || '请选择音色']"
label="TTS 音色"
required
@update:model-value="changeSource"
></v-select>
<v-switch <v-switch
v-model="setting.isFullscreen.value" v-model="setting.isFullscreen.value"
......
...@@ -24,11 +24,9 @@ router.beforeEach((g) => { ...@@ -24,11 +24,9 @@ router.beforeEach((g) => {
const microphoneState = ref<'waitInput' | 'input' | 'loading' | 'disabled'>('waitInput') const microphoneState = ref<'waitInput' | 'input' | 'loading' | 'disabled'>('waitInput')
async function initVosk({ async function initVosk({
modelPath,
result, result,
partialResult partialResult
}: { }: {
modelPath: string
result?: (string) => void result?: (string) => void
partialResult?: (string) => void partialResult?: (string) => void
}) { }) {
...@@ -102,7 +100,6 @@ async function startAudioInput() { ...@@ -102,7 +100,6 @@ async function startAudioInput() {
microphoneState.value = 'loading' microphoneState.value = 'loading'
const { recognizer, channel } = await initVosk({ const { recognizer, channel } = await initVosk({
modelPath: `https://resources.laihua.com/2023-11-29/${settings.voskSelectModel}`,
result: async (text) => { result: async (text) => {
console.log('----------------> text:', text) console.log('----------------> text:', text)
const tone = settings.source.find(({ sourceId }) => settings.selectSource === sourceId) const tone = settings.source.find(({ sourceId }) => settings.selectSource === sourceId)
......
...@@ -10,6 +10,7 @@ export type ISettings = { ...@@ -10,6 +10,7 @@ export type ISettings = {
asr: 'vosk_asr' | 'xf_asr' asr: 'vosk_asr' | 'xf_asr'
voskModels: string[] voskModels: string[]
voskSelectModel: string voskSelectModel: string
tts: 'xf_tts' | 'local_tts',
ttsHost: string ttsHost: string
source: { source: {
sourceName: string sourceName: string
...@@ -28,6 +29,7 @@ const useSettingsStore = defineStore('settings', { ...@@ -28,6 +29,7 @@ const useSettingsStore = defineStore('settings', {
state: () => state: () =>
({ ({
asr: 'vosk_asr', asr: 'vosk_asr',
tts: 'xf_tts',
voskModels: [ voskModels: [
'vosk-model-small-ca-0.4.tar.gz', 'vosk-model-small-ca-0.4.tar.gz',
'vosk-model-small-cn-0.3.tar.gz', 'vosk-model-small-cn-0.3.tar.gz',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment