feat(tts): 完善多模型语音界面并修复轮询闪烁
This commit is contained in:
parent
cf991bb5f3
commit
24186c5be0
9
.env.chengzhi
Normal file
9
.env.chengzhi
Normal file
@ -0,0 +1,9 @@
|
||||
VITE_APP_TITLE=城职语音语料管理平台
|
||||
VITE_APP_ENV=production
|
||||
VITE_APP_BASE_API=/prod-api
|
||||
VITE_API_URL=http://192.168.28.10:18200
|
||||
VITE_WS_URL=ws://192.168.28.10:18200/ws
|
||||
VITE_BUILD_COMPRESS=gzip
|
||||
VITE_INSPECTION_TYPE=inspection
|
||||
VITE_MINIO_URL=http://192.168.28.10:9000/cmvr-iot/
|
||||
PROJECT_NAME=cmvr
|
||||
@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE = 招商车研机器人智能测试管理系统
|
||||
VITE_APP_TITLE = 城职语音语料管理平台
|
||||
|
||||
# 开发环境配置
|
||||
VITE_APP_ENV = 'development'
|
||||
@ -7,8 +7,8 @@ VITE_APP_ENV = 'development'
|
||||
# 招商车研物联网平台/开发环境
|
||||
VITE_APP_BASE_API = '/dev-api'
|
||||
|
||||
VITE_API_URL = http://192.168.0.222:14080
|
||||
VITE_WS_URL = ws://192.168.0.222:14080/ws
|
||||
VITE_API_URL = http://127.0.0.1:14080
|
||||
VITE_WS_URL = ws://127.0.0.1:14080/ws
|
||||
VITE_PORT = 5174
|
||||
VITE_INSPECTION_TYPE = "inspection"
|
||||
VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/"
|
||||
|
||||
17
README.md
17
README.md
@ -126,3 +126,20 @@ src/views/evaluate/ 评价管理
|
||||
src/views/corpusManger/ 语料管理
|
||||
vite/ Vite 插件配置
|
||||
```
|
||||
|
||||
|
||||
## 城职语音合成与多情绪扩展
|
||||
|
||||
开发配置 `.env.development` 默认指向 `http://127.0.0.1:14080`,前端端口5174;本机可通过被忽略的 `.env.development.local` 覆盖。已有全局pnpm版本不匹配时,可用 `npm exec --yes --package=pnpm@10.24.0 -- pnpm install --frozen-lockfile` 安装,再用 `node node_modules/vite/bin/vite.js --host 127.0.0.1 --port 5174 --strictPort` 启动,不需要修改全局工具。
|
||||
|
||||
- 后端授权菜单入口为 `/corpusManger/speech_synthesis`(语音智能体)和 `/corpusManger/corpus`(语料库)。沿用管理员现有账号,不能绕过登录和权限。
|
||||
- 科大讯飞/自研模型可切换,音色目录从 `/tts/task/capabilities` 获取;本地目录用于中文名称显示及加载失败时的回退。讯飞仅保留本项目原15种音色加聆小芸 `x4_lingxiaoyun_talk_emo`,共16种,支持按语种和方言筛选。
|
||||
- 自研模型支持6种请求情绪以及补充说话指令,当前开放中文、原生48 kHz WAV;方言提示标注为需试听确认。自研服务不支持的速度、音量、音高控件不显示。
|
||||
- 泛化与翻译可将原句转换为目标语种,加入合成时联动语种和音色;提交前检查长度及重复,并拦截外语音色与中文误配。后端同样校验,不能只依靠界面。
|
||||
- 模型、语种、音色和情绪用中文名称显示;任务列表支持按模型/语种/情绪筛选,语料库支持模型/情绪筛选,保留真实分页总数和失败原因。
|
||||
- 播放、下载使用带登录认证的后端音频流,由后端读取MinIO,不要求MinIO桶公开,也不依赖本机D/E盘路径。
|
||||
- 看板使用真实统计,平均音频时长按秒显示;已使用音色/语种数量不当作完整服务能力数量。支持桌面和390像素宽移动布局,播放弹窗按视口收缩。
|
||||
- 合成页默认优先显示任务列表,点击“新建语音合成(点击展开)”打开配置;分类目录默认仅展开顶层并限制滚动高度,避免窄窗口下遮住语料列表。两处列表显示加载状态和失败重试提示;切换语料分类时回到第一页。
|
||||
- 任务列表每5秒静默检查更新,不显示加载遮罩;响应内容相同时保留原数组和行对象,变化时仅替换对应记录。以ID保持行身份,忽略过期查询响应,后台轮询不与未完成查询重叠,离开缓存页面时暂停轮询。
|
||||
|
||||
回归命令:`node --test`;构建:`node node_modules/vite/bin/vite.js build --mode development`。语音相关回归覆盖目录去重、音色中文标签、语种防错和文本去重。浏览器联调截图及记录位于被忽略的 `.local/`,不包含在源码或生产构建中。
|
||||
|
||||
@ -43,4 +43,5 @@ export function getDashboardApi() {
|
||||
url: '/tts/corpus/dashboard/stats',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
}
|
||||
export const getCorpusAudioApi = id => request({url: `/tts/corpus/audio/${id}`, method:'get', responseType:'blob'})
|
||||
|
||||
@ -48,6 +48,7 @@ export function regenerateApi(id) {
|
||||
export function generalizationApi(data) {
|
||||
return request({
|
||||
url: '/tts/task/llm/query',
|
||||
timeout: 240000,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -56,6 +57,7 @@ export function generalizationApi(data) {
|
||||
export function batchTaskApi(data) {
|
||||
return request({
|
||||
url: '/tts/task/batch',
|
||||
timeout: 300000,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -66,4 +68,5 @@ export function saveTaskApi(data) {
|
||||
url: `/tts/task/save-to-corpus/${data.taskId}/${data.categoryId}`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
}
|
||||
export const getCapabilitiesApi = () => request({ url: '/tts/task/capabilities', method: 'get' })
|
||||
|
||||
151
src/data/tts-voices.json
Normal file
151
src/data/tts-voices.json
Normal file
@ -0,0 +1,151 @@
|
||||
{
|
||||
"source": "official-live",
|
||||
"voices": [
|
||||
{
|
||||
"voice": "x4_yezi",
|
||||
"label": "讯飞小露",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "普通话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x4_lingbosong",
|
||||
"label": "聆伯松·标准",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "普通话",
|
||||
"gender": "男声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x_xiaomei",
|
||||
"label": "讯飞小梅",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "广东话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x3_yezi_sc",
|
||||
"label": "叶子 ",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "四川话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x4_xiaobei",
|
||||
"label": "小北",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "东北话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_xiaokun",
|
||||
"label": "讯飞小坤",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "河南话",
|
||||
"gender": "男声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_xiaoying",
|
||||
"label": "讯飞小莹",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "陕西话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_xiaodong",
|
||||
"label": "讯飞小东",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "山东话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_xiaoqiang",
|
||||
"label": "讯飞小强",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "湖南话",
|
||||
"gender": "男声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_xiaowang",
|
||||
"label": "讯飞小王",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "湖北话",
|
||||
"gender": "男声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x4_enus_ryan_assist",
|
||||
"label": "Ryan",
|
||||
"language": "en-US",
|
||||
"languageLabel": "英语(美国)",
|
||||
"dialect": "",
|
||||
"gender": "男声",
|
||||
"verified": true,
|
||||
"country": "美国"
|
||||
},
|
||||
{
|
||||
"voice": "x2_JaJp_ZhongCun",
|
||||
"label": "ZhongCun",
|
||||
"language": "ja-JP",
|
||||
"languageLabel": "日语",
|
||||
"dialect": "",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_KoKr_Miya",
|
||||
"label": "miya",
|
||||
"language": "ko-KR",
|
||||
"languageLabel": "韩语",
|
||||
"dialect": "",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_RuRu_Keshu",
|
||||
"label": "keshu",
|
||||
"language": "ru-RU",
|
||||
"languageLabel": "俄语",
|
||||
"dialect": "",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x2_DeDe_Christiane",
|
||||
"label": "christiane",
|
||||
"language": "de-DE",
|
||||
"languageLabel": "德语",
|
||||
"dialect": "",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"voice": "x4_lingxiaoyun_talk_emo",
|
||||
"label": "聆小芸-对话·多情感",
|
||||
"language": "zh-CN",
|
||||
"languageLabel": "中文",
|
||||
"dialect": "普通话",
|
||||
"gender": "女声",
|
||||
"verified": true
|
||||
}
|
||||
],
|
||||
"scope": "city-vocational-college-16"
|
||||
}
|
||||
11
src/utils/tableRefresh.js
Normal file
11
src/utils/tableRefresh.js
Normal file
@ -0,0 +1,11 @@
|
||||
/** Keep unchanged records and arrays stable across background polling. */
|
||||
export function reconcileRows(current, incoming) {
|
||||
const previous = new Map(current.map(row => [row.id, row]))
|
||||
const next = incoming.map(row => {
|
||||
const old = previous.get(row.id)
|
||||
return old && JSON.stringify(old) === JSON.stringify(row) ? old : row
|
||||
})
|
||||
return next.length === current.length && next.every((row, index) => row === current[index])
|
||||
? current
|
||||
: next
|
||||
}
|
||||
19
src/utils/tts.js
Normal file
19
src/utils/tts.js
Normal file
@ -0,0 +1,19 @@
|
||||
import catalog from '../data/tts-voices.json' with { type: 'json' }
|
||||
export const modelLabels = { xfyun: '科大讯飞', voxcpm2: '自研模型', legacy: '原有服务', '科大讯飞': '科大讯飞' }
|
||||
export const emotionLabels = { neutral: '中性', happy: '开心', sad: '难过', angry: '生气', fearful: '害怕', surprised: '惊讶' }
|
||||
export const languageLabels = { 'zh-CN':'中文', 'en-US':'英语(美国)', 'en-GB':'英语(英国)', 'ja-JP':'日语', 'ko-KR':'韩语', 'ru-RU':'俄语', 'de-DE':'德语' }
|
||||
export const defaultCapabilities = { voices: catalog.voices, models: [{value:'xfyun',label:'科大讯飞'}, {value:'voxcpm2',label:'自研模型'}], emotions: Object.entries(emotionLabels).map(([value,label])=>({value,label})), selfDialects:['普通话','广东话','四川话','东北话','河南话','陕西话','山东话','湖南话','湖北话'] }
|
||||
const voiceMap = new Map(catalog.voices.map(v=>[v.voice,v]))
|
||||
export const voiceLabel = value => value === 'default' ? '自研默认音色' : (voiceMap.get(value)?.label || value || '未设置')
|
||||
export const languageLabel = value => languageLabels[value] || catalog.voices.find(v=>v.language===value)?.languageLabel || value || '未设置'
|
||||
export const emotionLabel = (value, model) => ((!model || model==='xfyun' || model==='科大讯飞') && (!value || value==='neutral')) ? '默认表达' : (emotionLabels[value] || value || '中性')
|
||||
export const modelLabel = value => modelLabels[value] || value || '科大讯飞'
|
||||
export const normalizedText = value => value.normalize('NFKC').toLocaleLowerCase().replace(/[\p{P}\p{Z}\s]/gu, '')
|
||||
export function prepareTexts(values, language) {
|
||||
const seen=new Set();return values.map(v=>v.trim()).filter(Boolean).map(text=>{
|
||||
if(text.length>100)throw new Error('每条语料不能超过100字符')
|
||||
if(language!=='zh-CN' && language!=='ja-JP' && /\p{Script=Han}/u.test(text))throw new Error('外语发音人不能朗读中文语料,请先翻译文本')
|
||||
if(language==='ja-JP' && !/[\p{Script=Hiragana}\p{Script=Katakana}]/u.test(text))throw new Error('日语语料需要包含日语假名')
|
||||
const key=normalizedText(text);if(seen.has(key))throw new Error('存在重复语料,请去重后提交');seen.add(key);return text
|
||||
})
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="category-panel">
|
||||
<div class="category-tree">
|
||||
<!-- 头部 -->
|
||||
<div class="tree-header">
|
||||
@ -10,7 +10,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 树 -->
|
||||
<el-tree ref="treeRef" :data="treeData" :props="defaultProps" default-expand-all highlight-current
|
||||
<el-tree ref="treeRef" class="category-nodes" :data="treeData" :props="defaultProps" :default-expanded-keys="['']" highlight-current
|
||||
node-key="id" @node-click="handleNodeClick">
|
||||
<template #default="{ data }">
|
||||
<div class="tree-node">
|
||||
@ -229,9 +229,16 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
.category-panel {
|
||||
height: 100%;
|
||||
}
|
||||
.category-nodes {
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
.category-nodes { max-height: 160px; }
|
||||
}
|
||||
.category-tree {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
@ -288,4 +295,4 @@ onMounted(() => {
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -1,25 +1,30 @@
|
||||
<template>
|
||||
<div class="corpus-list">
|
||||
<el-alert v-if="loadError" :title="loadError" type="error" :closable="false" show-icon>
|
||||
<el-button link type="primary" @click="getCorpusList">重新加载</el-button>
|
||||
</el-alert>
|
||||
<!-- 工具栏 -->
|
||||
<div class="list-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button type="primary" size="default" @click="openDialog(true)">+新建语料</el-button>
|
||||
<span>通过“语音合成”生成音频后,可在任务列表保存到语料库。</span>
|
||||
<el-select v-model="filterModel" clearable placeholder="全部模型" style="width:150px"><el-option label="科大讯飞" value="xfyun"/><el-option label="自研模型" value="voxcpm2"/></el-select>
|
||||
<el-select v-model="filterEmotion" clearable placeholder="全部情绪" style="width:130px"><el-option v-for="(label,value) in emotionLabels" :key="value" :label="label" :value="value"/></el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<el-table :data="corpusData" stripe style="width:100%;" max-height="400">
|
||||
<el-table v-loading="loading" :data="corpusData" stripe style="width:100%;" max-height="400">
|
||||
<el-table-column prop="id" label="语料编号" show-overflow-tooltip />
|
||||
<el-table-column prop="text" label="文本内容" show-overflow-tooltip />
|
||||
<el-table-column prop="categoryName" label="所属分类" show-overflow-tooltip />
|
||||
<el-table-column prop="language" label="语种" />
|
||||
<el-table-column prop="dialect" label="方言" />
|
||||
<el-table-column prop="emotion" label="情绪" />
|
||||
<el-table-column prop="voice" label="音色" />
|
||||
<el-table-column label="语种"><template #default="{row}">{{ languageLabel(row.language) }}</template></el-table-column>
|
||||
<el-table-column prop="dialect" label="方言" /><el-table-column label="模型"><template #default="{row}">{{ modelLabel(row.model) }}</template></el-table-column>
|
||||
<el-table-column label="情绪"><template #default="{row}">{{ emotionLabel(row.emotion, row.model) }}</template></el-table-column>
|
||||
<el-table-column label="音色"><template #default="{row}">{{ voiceLabel(row.voice) }}</template></el-table-column>
|
||||
<el-table-column prop="fileSize" label="文件大小" />
|
||||
<el-table-column label="操作" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link @click="play(row.audioFilePath)" type="primary" icon="VideoPlay">播放</el-button>
|
||||
<el-button link @click="play(row)" :disabled="!row.audioFilePath" type="primary" icon="VideoPlay">播放</el-button>
|
||||
<el-button icon="Download" link type="primary" @click="handleDownload(row)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -27,48 +32,12 @@
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-wrapper">
|
||||
<span>共 {{ total }} 条</span>
|
||||
<el-pagination background layout="prev, pager, next, jumper" :total="total" :page-size="10"
|
||||
v-model:current-page="page" small />
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="addCorpusVisible" :title="'新建语料'" :append-to-body="true" width="600px" @close="resetDialog">
|
||||
<el-form ref="ruleFormRef" :model="ruleForm" label-width="auto">
|
||||
<el-form-item label="模型" prop="model">
|
||||
<el-select v-model="ruleForm.model" placeholder="模型">
|
||||
<el-option label="科大讯飞" value="科大讯飞" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="文本" prop="text">
|
||||
<el-input type="textarea" :rows="2" v-model="ruleForm.text" placeholder="请输入文本" />
|
||||
</el-form-item>
|
||||
<el-form-item label="语种" prop="language">
|
||||
<el-select v-model="ruleForm.language" placeholder="语种">
|
||||
<el-option v-for="item in langOption" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="上传文件">
|
||||
<el-upload v-model:file-list="uploadFileList" :action="`${data.baseUrl}/system/file/upload`"
|
||||
:before-upload="beforeAvatarUpload" :data="{ fileType: uploadFileType }" :headers="{
|
||||
'authorization': getToken()
|
||||
}" :limit="1" :on-error="uploadError" :on-success="uploadSuccess" class="file-uploader">
|
||||
<el-button type="primary">选取文件</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
支持格式:'wav'
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="addCorpusVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmDialog">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="播放音频" width="600px" :destroy-on-close="true" @close="colseDialog">
|
||||
<el-dialog v-model="dialogVisible" title="播放音频" width="min(600px, calc(100vw - 24px))" :destroy-on-close="true" @close="colseDialog">
|
||||
<div class="wave-container">
|
||||
<div class="wave">
|
||||
<div v-for="(h, index) in waveform" :key="index" :style="{
|
||||
@ -88,10 +57,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import { getToken } from "@/utils/auth.js";
|
||||
import { getCorpusListApi } from '@/api/corpusManger/corpus.js'
|
||||
import { downloadWavApi } from '@/api/corpusManger/speech_synthesis'
|
||||
import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { voiceLabel, languageLabel, modelLabel, emotionLabel, emotionLabels } from '@/utils/tts'
|
||||
import { getCorpusListApi, getCorpusAudioApi } from '@/api/corpusManger/corpus.js'
|
||||
import AudioPlayer from '../../speech_synthesis/components/AudioPlayer.vue';
|
||||
|
||||
const props = defineProps({
|
||||
@ -101,109 +69,35 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const addCorpusVisible = ref(false)
|
||||
|
||||
const voiceOption = ref([
|
||||
{
|
||||
label: '女声',
|
||||
value: 'xiaoyan'
|
||||
}
|
||||
])
|
||||
|
||||
const langOption = ref([
|
||||
{
|
||||
label: '中文(普通话)',
|
||||
value: '普通话'
|
||||
}, {
|
||||
label: '英文',
|
||||
value: '英文'
|
||||
}, {
|
||||
label: '粤语',
|
||||
value: '粤语'
|
||||
}, {
|
||||
label: '四川话',
|
||||
value: '四川话'
|
||||
},
|
||||
])
|
||||
|
||||
const ruleForm = ref({
|
||||
text: '',
|
||||
model: '科大讯飞',
|
||||
voice: 'xiaoyan',
|
||||
speed: 50,
|
||||
volume: 50,
|
||||
pitch: 50,
|
||||
sampleRate: '16',
|
||||
outputFormat: 'wav'
|
||||
})
|
||||
|
||||
const rules = ref({
|
||||
text: [{ required: true, message: '请输入合成文本', trigger: 'blur' }],
|
||||
language: [{ required: true, message: '请选择语种', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const uploadFileList = ref([])
|
||||
const uploadFileType = ref(null)
|
||||
const data = {
|
||||
baseUrl: import.meta.env.VITE_APP_BASE_API
|
||||
}
|
||||
|
||||
const openDialog = () => {
|
||||
addCorpusVisible.value = true
|
||||
}
|
||||
|
||||
const resetDialog = () => {
|
||||
addCorpusVisible.value = false
|
||||
}
|
||||
|
||||
const page = ref(1)
|
||||
|
||||
const beforeAvatarUpload = (rawFile) => {
|
||||
const fileName = rawFile.name.split('.');
|
||||
const fileExt = fileName[fileName.length - 1];
|
||||
const isTypeOk = ['png', 'jpg', 'jpeg'].indexOf(fileExt) >= 0;
|
||||
if (!isTypeOk) {
|
||||
proxy.$modal.msgError(`文件格式不正确,请上传${['png', 'jpg', 'jpeg'].join("/")}格式文件!`);
|
||||
return false;
|
||||
}
|
||||
const { label = undefined, value = undefined } = supportType?.find(item => item.label === rawFile.type)
|
||||
if (label) {
|
||||
uploadFileType.value = value
|
||||
}
|
||||
// 校检文件大小
|
||||
|
||||
const isLt = rawFile.size / 1024 / 1024 < 5;
|
||||
if (!isLt) {
|
||||
ElMessage.error(`上传文件大小不能超过 ${5} MB!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const uploadSuccess = (e) => {
|
||||
imgUrl.value = e.msg
|
||||
ElMessage.success('上传成功')
|
||||
}
|
||||
const uploadError = (e) => {
|
||||
console.log("uploadError", e)
|
||||
}
|
||||
const filterModel=ref(''), filterEmotion=ref('')
|
||||
watch([filterModel,filterEmotion],()=>{page.value=1;getCorpusList()})
|
||||
watch(page,()=>getCorpusList())
|
||||
|
||||
// 模拟数据
|
||||
const corpusData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false), loadError = ref('')
|
||||
|
||||
const getCorpusList = async () => {
|
||||
const obj = {
|
||||
pageNum: page.value,
|
||||
pageSize: 10,
|
||||
categoryId: props.categoryId
|
||||
}
|
||||
const res = await getCorpusListApi(obj)
|
||||
if (res.code === 0) {
|
||||
corpusData.value = res.rows
|
||||
total.value = res.total
|
||||
categoryId: props.categoryId,
|
||||
model: filterModel.value,
|
||||
emotion: filterEmotion.value
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getCorpusListApi(obj)
|
||||
if (res.code === 200 || res.code === 0) {
|
||||
corpusData.value = res.rows
|
||||
total.value = res.total
|
||||
loadError.value = ''
|
||||
}
|
||||
} catch {
|
||||
loadError.value = '语料列表加载失败,请检查登录状态后重新加载。'
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +118,7 @@ const updateWaveform = () => {
|
||||
waveform.value = Array.from({ length: 60 }, () => Math.floor(Math.random() * 60 + 20))
|
||||
}
|
||||
|
||||
const audioUrl = ref('https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/music/audio.mp3')
|
||||
const audioUrl = ref('')
|
||||
|
||||
const audioStatus = (isPlaying) => {
|
||||
if (isPlaying) {
|
||||
@ -234,25 +128,27 @@ const audioStatus = (isPlaying) => {
|
||||
}
|
||||
}
|
||||
|
||||
const play = (url) => {
|
||||
const play = async (row) => {
|
||||
const blob = await getCorpusAudioApi(row.id)
|
||||
if(audioUrl.value) URL.revokeObjectURL(audioUrl.value)
|
||||
audioUrl.value = URL.createObjectURL(blob)
|
||||
dialogVisible.value = true
|
||||
audioUrl.value = import.meta.env.VITE_MINIO_URL + url
|
||||
}
|
||||
|
||||
const colseDialog = () => {
|
||||
dialogVisible.value = false
|
||||
if(audioUrl.value) {URL.revokeObjectURL(audioUrl.value);audioUrl.value=''}
|
||||
if (timer.value) clearInterval(timer.value)
|
||||
}
|
||||
|
||||
const handleDownload = async (row) => {
|
||||
const response = await fetch(import.meta.env.VITE_MINIO_URL + row.audioFilePath)
|
||||
const blob = await response.blob()
|
||||
const blob = await getCorpusAudioApi(row.id)
|
||||
const blobUrl = URL.createObjectURL(blob)
|
||||
|
||||
const a = document.createElement('a')
|
||||
a.href = blobUrl
|
||||
|
||||
a.download = `${row.id}.${row.audioFilePath.split('.')[1]}`
|
||||
a.download = `${row.id}.wav`
|
||||
a.click()
|
||||
|
||||
URL.revokeObjectURL(blobUrl)
|
||||
@ -260,7 +156,8 @@ const handleDownload = async (row) => {
|
||||
|
||||
watch(() => props.categoryId,
|
||||
() => {
|
||||
getCorpusList()
|
||||
if (page.value !== 1) page.value = 1
|
||||
else getCorpusList()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@ -268,6 +165,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if(audioUrl.value) URL.revokeObjectURL(audioUrl.value)
|
||||
if (timer.value) clearInterval(timer.value)
|
||||
})
|
||||
</script>
|
||||
@ -328,4 +226,4 @@ onBeforeUnmount(() => {
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, onBeforeUnmount } from 'vue'
|
||||
import SvgIcon from "@/components/SvgIcon";
|
||||
import { getDashboardApi } from '@/api/corpusManger/corpus.js'
|
||||
import { onMounted } from "vue";
|
||||
@ -27,29 +27,29 @@ const stats = ref([
|
||||
{
|
||||
iconName: 'task',
|
||||
label: '语料总量(条)',
|
||||
value: 14,
|
||||
trend: '+12.4%',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up'
|
||||
},
|
||||
{
|
||||
iconName: 'add',
|
||||
label: '核心功能分类(个)',
|
||||
value: '4',
|
||||
trend: '+8.7%',
|
||||
label: '已使用音色(个)',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up',
|
||||
},
|
||||
{
|
||||
iconName: 'language',
|
||||
label: '多语种数量(种)',
|
||||
value: 2,
|
||||
value: '—',
|
||||
trend: '—',
|
||||
trendClass: 'neutral'
|
||||
},
|
||||
{
|
||||
iconName: 'consuming',
|
||||
label: '今日新增语料(条)',
|
||||
value: 3,
|
||||
trend: '+3.2%',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up'
|
||||
}
|
||||
])
|
||||
@ -58,6 +58,8 @@ const getDashboard = async () => {
|
||||
const res = await getDashboardApi()
|
||||
if (res.code === 200) {
|
||||
stats.value[0].value = res.data.totalCorpus
|
||||
stats.value[1].value = res.data.totalVoices
|
||||
stats.value[0].trend = res.data.totalCorpusGrowth
|
||||
stats.value[2].value = res.data.totalLanguages
|
||||
stats.value[3].value = res.data.todayCorpus
|
||||
}
|
||||
@ -66,6 +68,9 @@ const getDashboard = async () => {
|
||||
onMounted(() => {
|
||||
getDashboard()
|
||||
})
|
||||
let statsTimer
|
||||
onMounted(() => { statsTimer=setInterval(() => { if(document.visibilityState==='visible') getDashboard() },10000) })
|
||||
onBeforeUnmount(() => clearInterval(statsTimer))
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -158,4 +163,7 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
<style scoped>
|
||||
.row-cards .card{min-width:0;padding:16px}.row-cards .card .flex-between{gap:12px}@media(max-width:650px){.row-cards{grid-template-columns:repeat(2,minmax(0,1fr))}.row-cards .card .flex-between .icon-container{display:none}}
|
||||
</style>
|
||||
|
||||
@ -39,7 +39,7 @@ const onSelectCategory = (node) => {
|
||||
|
||||
.main-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 260px 1fr;
|
||||
grid-template-columns: 260px minmax(0, 1fr);
|
||||
gap: 20px;
|
||||
align-items: start;
|
||||
flex: 1;
|
||||
@ -52,6 +52,7 @@ const onSelectCategory = (node) => {
|
||||
}
|
||||
|
||||
.right-panel {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
@ -68,6 +69,7 @@ const onSelectCategory = (node) => {
|
||||
|
||||
.left-panel {
|
||||
position: static;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -1,389 +1,62 @@
|
||||
<template>
|
||||
<div class="main-workspace">
|
||||
<div class="workspace-container">
|
||||
<div class="left">
|
||||
<div class="title">泛化语料</div>
|
||||
<el-form ref="generalizationFormRef" :rules="generalizationRules" :model="generalizationForm" label-position="top" label-width="auto">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="" prop="text">
|
||||
<el-input type="textarea" :rows="3" v-model="generalizationForm.text" placeholder="请输入待合成文本" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="语种" prop="language">
|
||||
<el-select v-model="generalizationForm.language" placeholder="语种">
|
||||
<el-option v-for="item in languageOption" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数量" prop="count">
|
||||
<el-input-number v-model="generalizationForm.count" :min="1" :max="10" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-row style="margin-top: 10px;" :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-button :loading="generalizationLoading" type="primary" :icon="VideoPlay" class="btn"
|
||||
@click="generalization">开始泛化</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button size="small" type="primary" plain :icon="Delete" class="btn"
|
||||
@click="generalizationCancel">清空</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div v-if="corpusList.length > 0" >
|
||||
<el-row style="margin: 10px 0;">
|
||||
<el-col :span="24">泛化语料列表</el-col>
|
||||
</el-row>
|
||||
<div class="corpus-container">
|
||||
<el-row :gutter="20" v-for="(item, index) in corpusList" style="margin-bottom: 4px;">
|
||||
<el-col :span="22" >
|
||||
<el-input v-model="corpusList[index]"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<el-button icon="Plus" @click="addTag(item)"></el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div class="title">
|
||||
文本与参数配置
|
||||
</div>
|
||||
<el-form ref="formRef" :rules="rules" :model="form" label-position="top" label-width="auto">
|
||||
<el-row>
|
||||
<el-form-item label="待合成语料" prop="tags">
|
||||
<el-tag v-for="tag in form.tags" :key="tag.name" closable @close="handleClose(tag)" class="tag">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="模型" prop="voice">
|
||||
<el-select v-model="form.model" placeholder="模型">
|
||||
<el-option label="科大讯飞" value="科大讯飞" />
|
||||
<el-option label="火山引擎" value="火山引擎" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="音色" prop="voice">
|
||||
<el-select v-model="form.voice" placeholder="音色">
|
||||
<el-option v-for="item in voiceOption" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="音量">
|
||||
<el-slider v-model="form.volume" :min="1" :max="100" :step="1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="语速" prop="speed">
|
||||
<el-slider v-model="form.speed" :min="1" :max="100" :step="1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="音高">
|
||||
<el-slider v-model="form.pitch" :min="1" :max="100" :step="1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="采样率">
|
||||
<el-select v-model="form.sampleRate" placeholder="采样率">
|
||||
<el-option label="8kHz" value="8000" />
|
||||
<el-option label="16kHz" value="16000" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="输出格式">
|
||||
<el-select v-model="form.outputFormat" placeholder="输出格式">
|
||||
<el-option label="WAV" value="wav" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;" :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-button :loading="loading" type="primary" :icon="VideoPlay" class="btn"
|
||||
@click="synthesis">开始合成</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button size="small" type="primary" plain :icon="Delete" class="btn"
|
||||
@click="cancel">清空</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="workspace-container">
|
||||
<section class="workspace-panel">
|
||||
<h3>文本准备与泛化</h3><p class="hint">保留操作对象、数字和方向,生成不同的自然表达。</p>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="原始文本"><el-input v-model="generalization.text" type="textarea" :rows="4" maxlength="100" show-word-limit placeholder="例如:请把空调温度调到二十二度。" /></el-form-item>
|
||||
<el-row :gutter="16"><el-col :span="16"><el-form-item label="泛化 / 翻译语种"><el-select v-model="generalization.language" filterable><el-option v-for="l in allLanguages" :key="l.value" :value="l.value" :label="l.label" /></el-select></el-form-item></el-col><el-col :span="8"><el-form-item label="生成数量"><el-input-number v-model="generalization.count" :min="1" :max="20" controls-position="right" /></el-form-item></el-col></el-row>
|
||||
<el-button type="primary" :loading="generalizing" @click="generalize">开始泛化</el-button><el-button :loading="generalizing" @click="translate">翻译为所选语种</el-button><el-button @click="addOriginal">使用原句</el-button>
|
||||
</el-form>
|
||||
<div v-if="variants.length" class="variants"><div class="panel-heading"><strong>泛化结果</strong><el-button link type="primary" @click="addAll">全部加入合成</el-button></div><div v-for="(_,i) in variants" :key="i" class="variant"><el-input v-model="variants[i]" maxlength="100" /><el-button @click="addGenerated(variants[i])">加入</el-button></div></div>
|
||||
</section>
|
||||
<section class="workspace-panel">
|
||||
<h3>语音合成</h3>
|
||||
<el-form label-position="top" @submit.prevent>
|
||||
<el-form-item label="合成模型"><el-radio-group v-model="form.model"><el-radio-button value="xfyun">科大讯飞</el-radio-button><el-radio-button value="voxcpm2">自研模型</el-radio-button></el-radio-group></el-form-item>
|
||||
<el-form-item label="待合成文本"><el-input v-model="textInput" type="textarea" :rows="4" placeholder="直接输入文本;每行一条,每批最多20条,每条最多100字符。" /></el-form-item>
|
||||
<div v-if="texts.length" class="tags"><el-tag v-for="(text,i) in texts" :key="i" closable @close="texts.splice(i,1)">{{ text }}</el-tag></div>
|
||||
<el-row :gutter="16"><el-col :span="12"><el-form-item label="合成语种"><el-select v-model="form.language" filterable><el-option v-for="l in languages" :key="l.value" :value="l.value" :label="l.label" /></el-select></el-form-item></el-col><el-col :span="12"><el-form-item :label="selfModel ? '方言提示(需试听确认)' : '方言 / 口音'"><el-select v-model="form.dialect"><el-option v-for="d in dialects" :key="d" :value="d" :label="d || '该语种默认口音'" /></el-select></el-form-item></el-col></el-row>
|
||||
<el-form-item label="发音人 / 音色"><el-select v-model="form.voice" filterable class="full-width" placeholder="搜索音色中文名称"><el-option v-for="v in filteredVoices" :key="v.voice" :value="v.voice" :label="v.label"><span>{{ v.label }} · {{ v.gender || '默认' }}</span><el-tag v-if="!selfModel" class="voice-tag" size="small" :type="v.verified?'success':'info'">{{ v.verified?'已试通':'授权待核实' }}</el-tag></el-option></el-select></el-form-item>
|
||||
<p v-if="!selfModel" class="hint">当前项目配置 {{ capabilities.voices.length }} 种讯飞音色;当前讯飞接口使用音色的默认表达,不提供指定情绪控制。</p>
|
||||
<el-form-item label="情绪"><el-select v-model="form.emotion" :disabled="!selfModel"><el-option v-for="e in capabilities.emotions" :key="e.value" :value="e.value" :label="selfModel ? e.label : (e.value === 'neutral' ? '默认表达' : e.label)" /></el-select></el-form-item>
|
||||
<template v-if="selfModel"><el-form-item label="补充说话要求(可选)"><el-input v-model="form.instructions" maxlength="500" show-word-limit type="textarea" :rows="2" placeholder="例如:语气克制、稍带笑意。无需填写合成文本。" /></el-form-item><p class="hint">自研模型通过说话指令控制情绪,返回原生48 kHz WAV。方言提示效果请先试听;当前不提供语速、音量和音高调节。</p></template>
|
||||
<el-row v-else :gutter="16"><el-col :span="8"><el-form-item label="语速"><el-slider v-model="form.speed" :min="0" :max="100" /></el-form-item></el-col><el-col :span="8"><el-form-item label="音量"><el-slider v-model="form.volume" :min="0" :max="100" /></el-form-item></el-col><el-col :span="8"><el-form-item label="音高"><el-slider v-model="form.pitch" :min="0" :max="100" /></el-form-item></el-col></el-row>
|
||||
<el-row :gutter="16"><el-col :span="12"><el-form-item label="采样率"><el-select v-model="form.sampleRate" :disabled="selfModel"><el-option v-for="rate in selfModel?['48000']:['8000','16000']" :key="rate" :label="`${Number(rate)/1000} kHz`" :value="rate" /></el-select></el-form-item></el-col><el-col :span="12"><el-form-item label="输出格式"><el-input model-value="WAV" disabled /></el-form-item></el-col></el-row>
|
||||
<el-button type="primary" :loading="submitting" @click="synthesize">开始合成</el-button><el-button :disabled="submitting" @click="clearTexts">清空文本</el-button>
|
||||
</el-form>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { Delete, VideoPlay } from '@element-plus/icons-vue'
|
||||
import { batchTaskApi, regenerateApi, generalizationApi } from '@/api/corpusManger/speech_synthesis'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
const generalizationFormRef = ref()
|
||||
const generalizationForm = ref({
|
||||
text: '',
|
||||
language: '普通话',
|
||||
count: 1
|
||||
})
|
||||
const generalizationRules = ref({
|
||||
text: [{ required: true, message: '请输入合成文本', trigger: 'blur' }],
|
||||
language: [{ required: true, message: '请选择语种', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
|
||||
const languageOption = ref([
|
||||
{
|
||||
label: '中文(普通话)',
|
||||
value: '普通话'
|
||||
}, {
|
||||
label: '英文',
|
||||
value: '英文'
|
||||
}, {
|
||||
label: '粤语',
|
||||
value: '粤语'
|
||||
}, {
|
||||
label: '四川话',
|
||||
value: '四川话'
|
||||
}, {
|
||||
label: '韩语',
|
||||
value: '韩语'
|
||||
}, {
|
||||
label: '日语',
|
||||
value: '日语'
|
||||
}, {
|
||||
label: '俄语',
|
||||
value: '俄语'
|
||||
}
|
||||
])
|
||||
|
||||
const corpusList = ref([])
|
||||
const generalizationLoading = ref(false)
|
||||
const generalization = async () => {
|
||||
const result = await generalizationFormRef.value.validate()
|
||||
if (result) {
|
||||
generalizationLoading.value = true
|
||||
const res = await generalizationApi(generalizationForm.value)
|
||||
if (res.code === 200) {
|
||||
corpusList.value = res.data
|
||||
ElMessage.success(res.msg)
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
generalizationLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const generalizationCancel = () => {
|
||||
generalizationFormRef.value.resetFields()
|
||||
}
|
||||
|
||||
const addTag = (data) => {
|
||||
console.log('data', data)
|
||||
form.value.tags.push(data)
|
||||
}
|
||||
|
||||
// ========================================================
|
||||
const handleClose = (tag) => {
|
||||
form.value.tags.splice(form.value.tags.indexOf(tag), 1)
|
||||
}
|
||||
|
||||
const form = ref({
|
||||
tags: [],
|
||||
model: '科大讯飞',
|
||||
voice: '',
|
||||
speed: 50,
|
||||
volume: 50,
|
||||
pitch: 50,
|
||||
sampleRate: '16000',
|
||||
outputFormat: 'wav'
|
||||
})
|
||||
|
||||
const formRef = ref(null)
|
||||
|
||||
const validateArray = (rule, value, callback) => {
|
||||
if (!Array.isArray(value) || value.length === 0) {
|
||||
callback(new Error('请至少添加一条语料'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const rules = reactive({
|
||||
model: [{ required: true, message: '请选择模型', trigger: 'blur' }],
|
||||
tags: [{ required: true, validator: validateArray, trigger: 'change' }],
|
||||
voice: [{ required: true, message: '请输入音色', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const dialectOption = ref([
|
||||
{
|
||||
label: '东北话',
|
||||
value: '东北话'
|
||||
}, {
|
||||
label: '四川话',
|
||||
value: '四川话'
|
||||
}, {
|
||||
label: '广东话',
|
||||
value: '广东话'
|
||||
}
|
||||
])
|
||||
|
||||
const voiceOption = ref([
|
||||
{
|
||||
label: '普通话-男声',
|
||||
value: 'x4_lingbosong'
|
||||
}, {
|
||||
label: '普通话-女声',
|
||||
value: 'x4_yezi'
|
||||
}, {
|
||||
label: '英语-女声',
|
||||
value: 'x4_EnUs_Laura_education'
|
||||
}, {
|
||||
label: '英语-男声',
|
||||
value: 'x4_enus_ryan_assist'
|
||||
}, {
|
||||
label: '粤语-女声',
|
||||
value: 'x3_xiaoyue'
|
||||
}, {
|
||||
label: '东北话-女声',
|
||||
value: 'x4_xiaobei'
|
||||
}, {
|
||||
label: '四川话-女声',
|
||||
value: 'x3_yezi_sc'
|
||||
}, {
|
||||
label: '韩语-女声',
|
||||
value: 'x2_KoKr_Miya'
|
||||
}, {
|
||||
label: '日语-女声',
|
||||
value: 'x2_JaJp_ZhongCun'
|
||||
}, {
|
||||
label: '俄语-女声',
|
||||
value: 'x2_RuRu_Keshu'
|
||||
}
|
||||
])
|
||||
|
||||
const emotionOption = ref([
|
||||
{
|
||||
label: '开心',
|
||||
value: '开心'
|
||||
}, {
|
||||
label: '严肃',
|
||||
value: '严肃'
|
||||
}, {
|
||||
label: '温和',
|
||||
value: '温和'
|
||||
}
|
||||
])
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const synthesis = async () => {
|
||||
const result = await formRef.value.validate()
|
||||
if (result) {
|
||||
const arr = []
|
||||
const obj = JSON.parse(JSON.stringify(form.value))
|
||||
delete obj.tags
|
||||
form.value.tags.forEach(item => {
|
||||
arr.push({
|
||||
...obj,
|
||||
text: item
|
||||
})
|
||||
})
|
||||
loading.value = true
|
||||
const res = await batchTaskApi(arr)
|
||||
if (res.code === 200) {
|
||||
emit('refresh')
|
||||
ElMessage.success(res.msg)
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const cancel = () => {
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
import { batchTaskApi, generalizationApi, getCapabilitiesApi } from '@/api/corpusManger/speech_synthesis'
|
||||
import { defaultCapabilities, languageLabel, normalizedText, prepareTexts } from '@/utils/tts'
|
||||
const emit=defineEmits(['refresh'])
|
||||
const capabilities=ref(defaultCapabilities)
|
||||
const generalization=reactive({text:'',language:'zh-CN',count:5})
|
||||
const variants=ref([]), texts=ref([]), textInput=ref(''), generalizing=ref(false), submitting=ref(false)
|
||||
const form=reactive({model:'xfyun',language:'zh-CN',dialect:'普通话',voice:'x4_yezi',emotion:'neutral',instructions:'',speed:50,volume:50,pitch:50,sampleRate:'16000',outputFormat:'wav'})
|
||||
const selfModel=computed(()=>form.model==='voxcpm2')
|
||||
const allLanguages=computed(()=>Array.from(new Map(capabilities.value.voices.map(v=>[v.language,{value:v.language,label:languageLabel(v.language)}])).values()))
|
||||
const languages=computed(()=>selfModel.value?[{value:'zh-CN',label:'中文'}]:allLanguages.value)
|
||||
const dialects=computed(()=>selfModel.value?capabilities.value.selfDialects:[...new Set(capabilities.value.voices.filter(v=>v.language===form.language).map(v=>v.dialect))])
|
||||
const filteredVoices=computed(()=>selfModel.value?[{voice:'default',label:'自研默认音色',gender:''}]:capabilities.value.voices.filter(v=>v.language===form.language && v.dialect===form.dialect))
|
||||
watch(()=>form.model,()=>{form.language='zh-CN';form.dialect='普通话';form.voice=selfModel.value?'default':'x4_yezi';form.emotion='neutral';form.sampleRate=selfModel.value?'48000':'16000';form.instructions=''})
|
||||
watch(()=>form.language,()=>{if(!dialects.value.includes(form.dialect))form.dialect=dialects.value[0] || ''})
|
||||
watch(filteredVoices,list=>{if(!list.some(v=>v.voice===form.voice))form.voice=list[0]?.voice || ''})
|
||||
function addText(text){if(!text.trim())return;const key=normalizedText(text);if(texts.value.some(t=>normalizedText(t)===key))return ElMessage.warning('该语料已加入');texts.value.push(text.trim())}
|
||||
function addOriginal(){addText(generalization.text)}
|
||||
function alignGeneratedLanguage(){if(selfModel.value && generalization.language!=='zh-CN'){ElMessage.warning('自研模型当前仅开放中文,请选择科大讯飞合成外语');return false}form.language=generalization.language;return true}
|
||||
function addGenerated(text){if(alignGeneratedLanguage())addText(text)}
|
||||
function addAll(){if(alignGeneratedLanguage())variants.value.forEach(addText)}
|
||||
function clearTexts(){texts.value=[];textInput.value=''}
|
||||
async function runGeneralization(count){if(!generalization.text.trim())return ElMessage.warning('请输入原始文本');generalizing.value=true;try{const res=await generalizationApi({...generalization,count,language:languageLabel(generalization.language)});variants.value=prepareTexts(res.data || [],generalization.language)}finally{generalizing.value=false}}
|
||||
function generalize(){return runGeneralization(generalization.count)}
|
||||
function translate(){return runGeneralization(1)}
|
||||
async function synthesize(){try{if(!form.voice)throw new Error('请选择音色');const values=prepareTexts([...texts.value,...textInput.value.split(/\r?\n/)],form.language);if(!values.length || values.length>20)throw new Error('每批请提交1至20条语料');submitting.value=true;const res=await batchTaskApi(values.map(text=>({...form,text})));if(res.code===200){ElMessage.success('合成任务已提交,请在下方查看结果');emit('refresh')}}catch(error){if(error.message)ElMessage.error(error.message)}finally{submitting.value=false}}
|
||||
onMounted(async()=>{try{const res=await getCapabilitiesApi();if(res.code===200)capabilities.value=res.data}catch{ElMessage.warning('暂时使用本地音色目录,请确认后端已更新')}})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.main-workspace {
|
||||
.workspace-container {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
|
||||
.right {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item--default) {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.left {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.corpus-container {
|
||||
max-height: 100px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-form-item--default) {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<style scoped>
|
||||
.workspace-container{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;align-items:start}.workspace-panel{min-width:0;background:#fff;padding:24px;border-radius:12px;border:1px solid #e8edf4}h3{margin:0 0 16px;font-size:18px;color:#1e293b}.hint{font-size:13px;line-height:1.7;color:#64748b}.full-width,.el-select{width:100%}.tags{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.tags .el-tag{height:auto;white-space:normal;line-height:1.6}.variant{display:flex;gap:8px;margin-top:10px}.panel-heading{display:flex;justify-content:space-between;align-items:center}.variants{margin-top:24px}.voice-tag{float:right;margin-left:12px}@media(max-width:1000px){.workspace-container{grid-template-columns:1fr}.workspace-panel{padding:18px}}
|
||||
</style>
|
||||
@ -25,36 +25,36 @@ const stats = ref([
|
||||
{
|
||||
iconName: 'task',
|
||||
label: '合成任务总数(条)',
|
||||
value: '13',
|
||||
trend: '+12.4%',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up'
|
||||
},
|
||||
{
|
||||
iconName: 'add',
|
||||
label: '今日新增合成(条)',
|
||||
value: '3',
|
||||
trend: '+8.7%',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up',
|
||||
},
|
||||
{
|
||||
iconName: 'language',
|
||||
label: '支持语种(种)',
|
||||
value: '4',
|
||||
label: '已使用语种(种)',
|
||||
value: '—',
|
||||
trend: '—',
|
||||
trendClass: 'neutral'
|
||||
},
|
||||
{
|
||||
iconName: 'consuming',
|
||||
label: '可用音色(个)',
|
||||
value: '3',
|
||||
trend: '+3.2%',
|
||||
label: '已使用音色(个)',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'up'
|
||||
},
|
||||
{
|
||||
iconName: 'timbre',
|
||||
label: '平均生成时延(ms)',
|
||||
value: '428',
|
||||
trend: '-5.6%',
|
||||
label: '平均音频时长(秒)',
|
||||
value: '—',
|
||||
trend: '',
|
||||
trendClass: 'down'
|
||||
}
|
||||
])
|
||||
@ -68,7 +68,7 @@ const getDashboard = async () => {
|
||||
stats.value[1].trend = res.data.todayTasksGrowth
|
||||
stats.value[2].value = res.data.totalLanguages
|
||||
stats.value[3].value = res.data.totalVoices
|
||||
stats.value[4].value = res.data.avgDuration.toFixed(2)
|
||||
stats.value[4].value = Number(res.data.avgDuration || 0).toFixed(2)
|
||||
stats.value[4].trend = res.data.avgDurationGrowth
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,10 @@ const getDashboard = async () => {
|
||||
onMounted(() => {
|
||||
getDashboard()
|
||||
})
|
||||
defineExpose({ getDashboard })
|
||||
let statsTimer
|
||||
onMounted(() => { statsTimer=setInterval(() => { if(document.visibilityState==='visible') getDashboard() },10000) })
|
||||
onBeforeUnmount(() => clearInterval(statsTimer))
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -168,4 +172,15 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
<style scoped>
|
||||
@media(max-width:650px){
|
||||
.row-cards{gap:8px}
|
||||
.row-cards .card{padding:10px}
|
||||
.row-cards .card .flex-between .right{gap:4px}
|
||||
.row-cards .card .flex-between .right .stat-number{font-size:22px;margin-top:0}
|
||||
}
|
||||
</style>
|
||||
<style scoped>
|
||||
.row-cards .card{min-width:0;padding:16px}.row-cards .card .flex-between{gap:12px}.row-cards .card .flex-between .stat-label{font-size:13px}@media(max-width:1100px){.row-cards{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:650px){.row-cards{grid-template-columns:repeat(2,minmax(0,1fr))}.row-cards .card .flex-between .icon-container{display:none}}
|
||||
</style>
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<div class="taskList-container">
|
||||
<el-alert v-if="loadError" :title="loadError" type="error" :closable="false" show-icon>
|
||||
<el-button link type="primary" @click="getTaskList">重新加载</el-button>
|
||||
</el-alert>
|
||||
<div class="flex-between mb-3">
|
||||
<span class="stat-label">合成任务列表</span>
|
||||
</div>
|
||||
@ -12,25 +15,34 @@
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="tasks" style="width:100%;" stripe>
|
||||
<el-table-column prop="taskCode" label="任务编号" />
|
||||
<el-table-column prop="text" label="文本内容" show-overflow-tooltip />
|
||||
<el-table-column prop="voice" label="音色" />
|
||||
<el-table-column prop="status" label="状态">
|
||||
<div class="task-filters">
|
||||
<el-select v-model="filterModel" clearable placeholder="全部模型"><el-option label="科大讯飞" value="xfyun"/><el-option label="自研模型" value="voxcpm2"/></el-select>
|
||||
<el-select v-model="filterEmotion" clearable placeholder="全部情绪"><el-option v-for="(label,value) in emotionLabels" :key="value" :label="label" :value="value"/></el-select>
|
||||
<el-select v-model="filterLanguage" clearable filterable placeholder="全部语种"><el-option v-for="l in taskLanguages" :key="l.value" :label="l.label" :value="l.value"/></el-select>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tasks" row-key="id" style="width:100%;" stripe>
|
||||
<el-table-column prop="taskCode" label="任务编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="text" label="文本内容" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="模型" width="110"><template #default="{row}">{{ modelLabel(row.model) }}</template></el-table-column>
|
||||
<el-table-column label="语种 / 方言" width="130"><template #default="{row}">{{ languageLabel(row.language) }}<span v-if="row.dialect"> · {{ row.dialect }}</span></template></el-table-column>
|
||||
<el-table-column label="音色" width="145"><template #default="{row}">{{ voiceLabel(row.voice) }}</template></el-table-column>
|
||||
<el-table-column label="情绪" width="80"><template #default="{row}">{{ emotionLabel(row.emotion, row.model) }}</template></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="115">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType(row.status)" size="small" effect="plain">
|
||||
{{ row.statusName }}
|
||||
{{ row.statusName || ({0:"待处理",1:"合成中",2:"已完成",3:"失败"})[row.status] }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="audioDuration" label="时间">
|
||||
<el-table-column prop="errorMsg" label="失败原因" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="audioDuration" label="时长" width="70">
|
||||
<template #default="scope">
|
||||
{{ formatTime(scope.row.audioDuration) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" class-name="small-padding fixed-width" label="操作">
|
||||
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="155" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link @click="play(scope.row.audioFilePath)" type="primary"
|
||||
<el-button link @click="play(scope.row)" :disabled="scope.row.status !== '2'" type="primary"
|
||||
icon="VideoPlay">播放</el-button>
|
||||
<el-button icon="Delete" link type="primary" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||
|
||||
@ -64,7 +76,7 @@
|
||||
v-model:current-page="page" small />
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="播放音频" width="600px" :destroy-on-close="true" @close="colseDialog">
|
||||
<el-dialog v-model="dialogVisible" title="播放音频" width="min(600px, calc(100vw - 24px))" :destroy-on-close="true" @close="colseDialog">
|
||||
<div class="wave-container">
|
||||
<div class="wave">
|
||||
<div v-for="(h, index) in waveform" :key="index" :style="{
|
||||
@ -81,9 +93,9 @@
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="corpusDialogVisible" title="保存到语料库" :append-to-body="true" width="400px" @close="colseDialog">
|
||||
<el-dialog v-model="corpusDialogVisible" title="保存到语料库" :append-to-body="true" width="min(400px, calc(100vw - 24px))" @close="colseDialog">
|
||||
<el-form ref="formRef" :model="form" label-width="auto">
|
||||
<el-form-item label="语料分类" :rules="[{ required: true, message: '请选择分类', trigger: 'blur' }]">
|
||||
<el-form-item label="语料分类" prop="categoryId" :rules="[{ required: true, message: '请选择分类', trigger: 'blur' }]">
|
||||
<el-tree-select
|
||||
v-model="form.categoryId"
|
||||
:data="treeData"
|
||||
@ -107,7 +119,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, onMounted, onBeforeUnmount, onActivated, onDeactivated, watch } from 'vue'
|
||||
import { reconcileRows } from '@/utils/tableRefresh'
|
||||
import { voiceLabel, modelLabel, languageLabel, emotionLabel, emotionLabels, defaultCapabilities } from '@/utils/tts'
|
||||
import { taskListApi, deleteTask, downloadWavApi, regenerateApi, saveTaskApi } from '@/api/corpusManger/speech_synthesis'
|
||||
import { getCategoryTreeApi } from '@/api/corpusManger/corpus.js'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
@ -115,6 +129,9 @@ import Download from '@/plugins/download'
|
||||
import AudioPlayer from './AudioPlayer.vue';
|
||||
|
||||
const search = ref('')
|
||||
const filterModel=ref(''), filterEmotion=ref(''), filterLanguage=ref('')
|
||||
const taskLanguages=Array.from(new Map(defaultCapabilities.voices.map(v=>[v.language,{value:v.language,label:languageLabel(v.language)}])).values())
|
||||
watch([filterModel,filterEmotion,filterLanguage],()=>{page.value=1;getTaskList()})
|
||||
const activeTab = ref('')
|
||||
const page = ref(1)
|
||||
|
||||
@ -127,10 +144,12 @@ const tabs = [
|
||||
|
||||
const tasks = ref([])
|
||||
|
||||
const totalTasks = computed(() => tasks.value.length)
|
||||
const totalTasks = ref(0)
|
||||
const loading = ref(false), loadError = ref('')
|
||||
|
||||
const changeTab = (key) => {
|
||||
activeTab.value = key
|
||||
page.value = 1
|
||||
getTaskList()
|
||||
}
|
||||
|
||||
@ -147,18 +166,39 @@ const formatTime = (seconds) => {
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
const getTaskList = async (status = null) => {
|
||||
let requestVersion = 0, pendingRequests = 0, active = true
|
||||
onActivated(() => { active = true })
|
||||
onDeactivated(() => { active = false; requestVersion++; loading.value = false })
|
||||
const getTaskList = async (options = {}) => {
|
||||
const silent = options?.silent === true
|
||||
if (silent && pendingRequests) return
|
||||
const version = ++requestVersion
|
||||
pendingRequests++
|
||||
const obj = {
|
||||
pageNum: page.value,
|
||||
pageSize: 10,
|
||||
model: filterModel.value,
|
||||
emotion: filterEmotion.value,
|
||||
language: filterLanguage.value,
|
||||
}
|
||||
if (activeTab.value) {
|
||||
obj.status = activeTab.value
|
||||
}
|
||||
const res = await taskListApi(obj)
|
||||
if (res.code == 0) {
|
||||
tasks.value = res.rows
|
||||
totalTasks.value = res.total
|
||||
if (!silent) loading.value = true
|
||||
try {
|
||||
const res = await taskListApi(obj)
|
||||
if (version !== requestVersion) return
|
||||
if (res.code === 200 || res.code === 0) {
|
||||
const next = reconcileRows(tasks.value, res.rows)
|
||||
if (next !== tasks.value) tasks.value = next
|
||||
totalTasks.value = res.total
|
||||
loadError.value = ''
|
||||
}
|
||||
} catch {
|
||||
if (version === requestVersion && !silent) loadError.value = '合成任务加载失败,请检查登录状态后重新加载。'
|
||||
} finally {
|
||||
pendingRequests--
|
||||
if (version === requestVersion) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +213,7 @@ const updateWaveform = () => {
|
||||
waveform.value = Array.from({ length: 60 }, () => Math.floor(Math.random() * 60 + 20))
|
||||
}
|
||||
|
||||
const audioUrl = ref('https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/music/audio.mp3')
|
||||
const audioUrl = ref('')
|
||||
|
||||
const audioStatus = (isPlaying) => {
|
||||
if (isPlaying) {
|
||||
@ -187,13 +227,16 @@ onBeforeUnmount(() => {
|
||||
if (timer.value) clearInterval(timer.value)
|
||||
})
|
||||
|
||||
const play = (url) => {
|
||||
const play = async (row) => {
|
||||
const audio = await downloadWavApi(row.id)
|
||||
if (audioUrl.value) URL.revokeObjectURL(audioUrl.value)
|
||||
audioUrl.value = URL.createObjectURL(audio instanceof Blob ? audio : new Blob([audio], {type:'audio/wav'}))
|
||||
dialogVisible.value = true
|
||||
audioUrl.value = import.meta.env.VITE_MINIO_URL + url
|
||||
}
|
||||
|
||||
const colseDialog = () => {
|
||||
dialogVisible.value = false
|
||||
if (audioUrl.value) { URL.revokeObjectURL(audioUrl.value); audioUrl.value = '' }
|
||||
if (timer.value) clearInterval(timer.value)
|
||||
}
|
||||
|
||||
@ -267,9 +310,10 @@ const confirmCorpus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTaskList()
|
||||
})
|
||||
watch(page, getTaskList)
|
||||
let refreshTimer
|
||||
onMounted(() => { getTaskList(); refreshTimer = setInterval(() => { if(active && document.visibilityState==='visible' && page.value===1 && !dialogVisible.value && !corpusDialogVisible.value) getTaskList({ silent: true }) }, 5000) })
|
||||
onBeforeUnmount(() => { active = false; requestVersion++; clearInterval(refreshTimer); if(audioUrl.value) URL.revokeObjectURL(audioUrl.value) })
|
||||
|
||||
defineExpose({
|
||||
getTaskList
|
||||
@ -341,4 +385,7 @@ defineExpose({
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
<style scoped>
|
||||
.task-filters{display:flex;flex-wrap:wrap;gap:10px;margin:12px 0}.task-filters .el-select{width:150px}@media(max-width:650px){.taskList-container :deep(.el-pagination__jump){display:none}}
|
||||
</style>
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
<div class="page-container">
|
||||
<!-- 统计卡片 -->
|
||||
<div class="statCards">
|
||||
<StatCards />
|
||||
<StatCards ref="statsRef" />
|
||||
</div>
|
||||
|
||||
<!-- 主工作区 -->
|
||||
<div class="mainWorkspace">
|
||||
<MainWorkspace @refresh="refresh" />
|
||||
</div>
|
||||
<el-collapse v-model="openPanels" class="mainWorkspace">
|
||||
<el-collapse-item name="create" title="新建语音合成(点击展开)">
|
||||
<MainWorkspace @refresh="refresh" />
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<!-- 任务列表 -->
|
||||
<TaskList ref="taskListRef" />
|
||||
@ -21,8 +22,11 @@ import MainWorkspace from './components/MainWorkspace.vue'
|
||||
import TaskList from './components/TaskList.vue'
|
||||
|
||||
const taskListRef = ref()
|
||||
const statsRef = ref()
|
||||
const openPanels = ref([])
|
||||
const refresh = () => {
|
||||
taskListRef.value.getTaskList()
|
||||
statsRef.value.getDashboard()
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
22
tests/tableRefresh.test.js
Normal file
22
tests/tableRefresh.test.js
Normal file
@ -0,0 +1,22 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { reconcileRows } from '../src/utils/tableRefresh.js'
|
||||
|
||||
test('unchanged poll preserves array and record identity', () => {
|
||||
const rows = [{ id: 'a', status: '1', text: '原文' }]
|
||||
assert.equal(reconcileRows(rows, JSON.parse(JSON.stringify(rows))), rows)
|
||||
})
|
||||
test('changed status replaces only the changed record', () => {
|
||||
const rows = [{ id: 'a', status: '1' }, { id: 'b', status: '2' }]
|
||||
const next = reconcileRows(rows, [{ id: 'a', status: '2' }, { id: 'b', status: '2' }])
|
||||
assert.notEqual(next, rows)
|
||||
assert.equal(next[0].status, '2')
|
||||
assert.equal(next[1], rows[1])
|
||||
})
|
||||
test('insertions, removals and reordered pages remain accurate', () => {
|
||||
const rows = [{ id: 'a' }, { id: 'b' }]
|
||||
const reordered = reconcileRows(rows, [{ id: 'b' }, { id: 'a' }])
|
||||
assert.equal(reordered[0], rows[1])
|
||||
assert.deepEqual(reconcileRows(rows, [{ id: 'c' }, { id: 'b' }]).map(row => row.id), ['c', 'b'])
|
||||
assert.deepEqual(reconcileRows(rows, []), [])
|
||||
})
|
||||
25
tests/tts.test.js
Normal file
25
tests/tts.test.js
Normal file
@ -0,0 +1,25 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { defaultCapabilities, voiceLabel, emotionLabel, languageLabel, modelLabel, prepareTexts } from '../src/utils/tts.js'
|
||||
|
||||
test('项目只提供原15种讯飞音色和聆小芸,中文翻译与实际参数对应',()=>{
|
||||
const voices=defaultCapabilities.voices
|
||||
assert.equal(voices.length,16)
|
||||
assert.equal(new Set(voices.map(v=>v.voice)).size,voices.length)
|
||||
assert.equal(voices.filter(v=>v.verified).length,16)
|
||||
assert.ok(voices.some(v=>v.voice==='x4_lingxiaoyun_talk_emo'))
|
||||
assert.ok(!voices.some(v=>v.voice==='x4_lingfeizhe_emo'))
|
||||
assert.match(voiceLabel('x2_DeDe_Christiane'),/christiane|Christiane|克里/i)
|
||||
assert.equal(languageLabel('de-DE'),'德语')
|
||||
assert.equal(modelLabel('voxcpm2'),'自研模型')
|
||||
assert.equal(emotionLabel('fearful'),'害怕')
|
||||
})
|
||||
test('外语音色不能接收中文,日语必须含假名',()=>{
|
||||
for(const language of ['en-US','de-DE','ru-RU','ko-KR','ja-JP']) assert.throws(()=>prepareTexts(['请打开空调。'],language))
|
||||
assert.deepEqual(prepareTexts(['エアコンをつけて。'],'ja-JP'),['エアコンをつけて。'])
|
||||
})
|
||||
test('提交前检查规范化重复及每条长度',()=>{
|
||||
assert.throws(()=>prepareTexts(['Please stop!','please stop.'],'en-US'))
|
||||
assert.throws(()=>prepareTexts(['请'.repeat(101)],'zh-CN'))
|
||||
assert.deepEqual(prepareTexts([' 请打开空调。 ',''],'zh-CN'),['请打开空调。'])
|
||||
})
|
||||
@ -58,7 +58,7 @@ function createViteConfig({ mode, command }) {
|
||||
server: {
|
||||
port: Number(VITE_PORT || 80),
|
||||
host: true,
|
||||
open: true,
|
||||
open: false,
|
||||
proxy: {
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
'/dev-api': {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user