Commit 43a0654c by haojie

v2最后一次提交

parent ee229ea4
......@@ -99,6 +99,13 @@ export const getRoutes = () => {
component: () => import('@/pages/VocalCustomization/index.vue'),
meta: { title: 'snowhome', keepAlive: true },
},
// 动作创建
{
path: routerConfig.createAction.path,
name: routerConfig.createAction.name,
component: () => import('@/pages/createAction/index.vue'),
meta: { title: 'snowhome', keepAlive: true },
},
];
}
};
......
<template>
<div class=""></div>
</template>
<script lang="ts" setup></script>
<style lang="less" scoped></style>
......@@ -163,13 +163,16 @@ const digitalList = reactive({
const findIdinList = () => {
if (route.query.id) {
let status = 0;
// 找到对应的id
let index1 = digitalList.my.findIndex((item: any) => item.id == route.query.id);
if (index1 !== -1) {
status = 1;
currentCard.value = digitalList.my[index1].id;
}
let index2 = digitalList.admin.findIndex((item: any) => item.id == route.query.id);
if (index2 !== -1) {
status = 2;
currentCard.value = digitalList.admin[index2].id;
}
if (currentCard.value) {
......@@ -177,6 +180,14 @@ const findIdinList = () => {
[createLiveKeys.id]: currentCard.value,
};
commitInfo(params);
let row = {};
if (status == 1) {
row = digitalList.my.find((item: any) => item.id == currentCard.value);
} else if (status == 2) {
row = digitalList.admin.find((item: any) => item.id == currentCard.value);
}
// 更新右侧的视频
getVideoPath(row);
}
}
};
......
......@@ -29,13 +29,7 @@
>测试文案</Button
>
</template>
<div
class="right-chose-tones"
:style="{
width: !lists.soundColor.length ? '120px' : '',
}"
v-show="currentOption === scriptTypeText"
>
<div class="right-chose-tones" v-show="currentOption === scriptTypeText">
<div @click="tonesVisible = true" class="default-label">
<SelectionPopup
v-model="tonesVisible"
......@@ -632,7 +626,6 @@ onMounted(async () => {
align-items: center;
flex: 0 0 auto;
.right-chose-tones {
width: 245px;
height: 50px;
border-radius: 6px;
border: 1px solid #0dd;
......@@ -645,6 +638,9 @@ onMounted(async () => {
font-weight: 600;
font-size: @size-14;
cursor: pointer;
height: 100%;
.dja();
width: 120px;
}
.default-add {
color: rgb(180, 180, 180);
......
......@@ -73,7 +73,15 @@ import HomeSvg from '@/assets/svg/createLive/home.svg';
import InteractSvg from '@/assets/svg/createLive/interact.svg';
import ScriptsSvg from '@/assets/svg/createLive/scripts.svg';
import { computed, onBeforeMount, ref, onBeforeUnmount, onActivated } from 'vue';
import { getElBounding, show_message, DataType, dimensionalConvert, ecursionDeepCopy, getFile } from '@/utils/tool';
import {
getElBounding,
show_message,
DataType,
dimensionalConvert,
ecursionDeepCopy,
getFile,
getFileSuffixInUrl,
} from '@/utils/tool';
import { getDurationOfAudioFile } from '@/utils/audio';
import { useStore } from 'vuex';
import {
......@@ -83,11 +91,12 @@ import {
mergeSameAudio,
filterFiled,
getAudioUrl,
getAudioUrlKey,
} from '@/service/CreateLive';
import { getLiveTaskInfo, createDrafts, getDraftsDetail, liveTts, createLiveTask } from '@/utils/api/userApi';
import { useRoute, onBeforeRouteLeave } from 'vue-router';
import routerConfig from '@/router/tool';
import { onUpdateLiveTask } from '@/service/Common';
import { onUpdateLiveTask, getUploadConfig } from '@/service/Common';
import { callPyjsInWindow, writeLog, injectWindow } from '@/utils/pyqt';
import { useLiveInfoSubmit } from '@/hooks/useStoreCommit';
import { processTextCallback } from '@/hooks/useScript';
......@@ -129,6 +138,8 @@ const toolHeight = ref(0);
const videoPlay = ref<HTMLVideoElement>();
// 统计本次音频转换任务总数
const audioConvertTaskTotal = ref(0);
// 统计本次音频切割任务总数
const audioSplitTaskTotal = ref(0);
......@@ -409,7 +420,7 @@ const editAudioSave = async () => {
await audioScriptEditSubmit();
} else {
// v2
audioSplitV2('update');
audioConvert('update');
}
} catch (e) {
writeLog({
......@@ -505,7 +516,7 @@ const audioSplit = async () => {
// 开始切割前先判断文件类型
let result = await splitAudio(row.file.raw, audioSplitNum);
if (result.length) {
// 上传阿里云
// 上传阿里云--加个判断,没有长度抛出异常
let alyList = await uploadToAly(result);
let list = [];
alyList.forEach((aly: any) => {
......@@ -523,6 +534,43 @@ const audioSplit = async () => {
}
};
// python转换音频回调
const convertCallback = (convertInfo: any) => {
console.log('转换回调', convertInfo);
let num = 0;
if ('url' in convertInfo && 'new_url' in convertInfo && 'type' in convertInfo) {
let audioScriptList = createLiveInfo.value[createLiveKeys.audioScriptList];
// 根据切割前的链接匹配更新
for (let i = 0; i < audioScriptList.length; i++) {
let item = audioScriptList[i];
for (let j = 0; j < item.data.length; j++) {
let row = item.data[j];
if (getAudioUrl(row) == convertInfo.url) {
// 更新url
let key = getAudioUrlKey(row);
row[key] = convertInfo.new_url;
row.py_convert = true;
}
// 统计完成数量
if (row.py_convert) {
num += 1;
}
}
}
if (audioConvertTaskTotal.value === num) {
console.log('所有转换已经处理完成,开始切割');
audioSplitV2(convertInfo.type);
}
} else {
//
console.log('转换回调错误');
writeLog({
name: 'python convert callback error',
value: convertInfo,
});
}
};
// python切割回调
const splitCallback = (splitInfo: any) => {
console.log(splitInfo);
......@@ -568,13 +616,60 @@ const splitCallback = (splitInfo: any) => {
}
};
// 音频转换提交到python
const audioConvertToPython = async (row: any, type: string) => {
let config = await getUploadConfig();
// 通知python合并
callPyjsInWindow('audioConvert', {
url: getAudioUrl(row),
id: route.query.id,
type: type,
config: config,
});
// 更新状态
row.py_convert = false;
// 统计总次数
audioConvertTaskTotal.value += 1;
};
// 音频转换
const audioConvert = async (type: string) => {
let list = createLiveInfo.value[createLiveKeys.audioScriptList];
// 清空总任务数
audioConvertTaskTotal.value = 0;
for (let i = 0; i < list.length; i++) {
let item = list[i];
for (let j = 0; j < item.data.length; j++) {
let row = item.data[j];
if (row.children && row.children.length > 1) {
// 编辑时没有修改参数
continue;
}
// 判断文件后缀
let audio_url = getAudioUrl(row);
let suffix = getFileSuffixInUrl(audio_url);
if (suffix === 'wav') {
console.log('是wav文件,开始转换', audio_url);
audioConvertToPython(row, type);
} else {
console.log('不是wav', audio_url);
}
}
}
if (audioConvertTaskTotal.value === 0) {
// 没有要转换的,直接切割
audioSplitV2(type);
}
};
// 音频切割v2
const audioSplitV2 = async (type: string) => {
// 先将所有的音频转换成MP3
let list = createLiveInfo.value[createLiveKeys.audioScriptList];
// 清空总次数
audioSplitTaskTotal.value = 0;
for (let i = 0; i < createLiveInfo.value[createLiveKeys.audioScriptList].length; i++) {
let item = createLiveInfo.value[createLiveKeys.audioScriptList][i];
for (let i = 0; i < list.length; i++) {
let item = list[i];
for (let j = 0; j < item.data.length; j++) {
let row = item.data[j];
if (row.children && row.children.length > 1) {
......@@ -617,6 +712,16 @@ const audioSplitV2 = async (type: string) => {
}
}
}
if (audioSplitTaskTotal.value === 0) {
// 没有要切割的,直接提交
if (type == 'create') {
// 创建
audioScriptLiveTaskSubmit();
} else {
// 更新
audioScriptEditSubmit();
}
}
};
// 音频脚本直播创建
......@@ -646,7 +751,7 @@ const audioSubmit = async () => {
await audioScriptLiveTaskSubmit();
} else {
// v2版本,提交到python处理
audioSplitV2('create');
audioConvert('create');
}
} catch (e) {
writeLog({
......@@ -727,6 +832,8 @@ onActivated(() => {
enterPageEvent();
// 注入切割回调
injectWindow('splitAudioCallback', splitCallback);
// 转换回调
injectWindow('convertCallback', convertCallback);
});
// 路由离开前保存query
......
......@@ -82,6 +82,7 @@ import Button from '@/components/Button.vue';
import { callPyjsInWindow, injectWindow } from '@/utils/pyqt';
import { jumpToCreateLivePage } from '@/router/jump';
import { useStore } from 'vuex';
import { getFileSuffixInUrl } from '@/utils/tool';
const router = useRouter();
const store = useStore();
......@@ -102,6 +103,7 @@ const imgs = {
profile: new URL('../../assets/svg/home/profile.svg', import.meta.url).href,
speaking: new URL('../../assets/svg/home/speaking.svg', import.meta.url).href,
interaction: new URL('../../assets/svg/home/interaction.svg', import.meta.url).href,
action: new URL('../../assets/svg/home/action.svg', import.meta.url).href,
};
const toolList = [
{
......@@ -122,6 +124,12 @@ const toolList = [
path: routerConfig.createInteract.path,
name: routerConfig.createInteract.name,
},
// {
// label: '动作创建',
// icon: imgs.action,
// path: routerConfig.createAction.path,
// name: routerConfig.createAction.name,
// },
];
// 刷新我的数字人
......@@ -212,6 +220,16 @@ const startTest = async () => {
// duration: audioSplitDuration,
// id: 1,
// });
console.log(
getFileSuffixInUrl(
'http://yunyi-live.oss-cn-hangzhou.aliyuncs.com/upload/1/2023-08-11dd2372d8-73ff-4526-bf59-b1618a3f218f.mp3',
),
);
console.log(
getFileSuffixInUrl(
'http://nls-cloud-cn-shanghai.oss-cn-shanghai.aliyuncs.com/jupiter-flow/tmp/ad08fa0a70ae4ea88d11ad5e394ce045.wav?Expires=1692149777&OSSAccessKeyId=LTAIUpwNp2H7pBG5&Signature=D93qMT1DovslSOVa9oufV2cGZxE%3D',
),
);
};
onMounted(() => {
......
......@@ -44,4 +44,8 @@ export default {
path: '/VocalCustomization',
name: 'VocalCustomization',
},
createAction: {
path: '/createAction',
name: 'createAction',
},
};
......@@ -174,6 +174,23 @@ export const getAudioUrl = (item: any) => {
return item.url;
} else if (item.audio_url) {
return item.url;
} else if (item.old_content) {
return item.old_content;
} else if (item.content) {
return item.content;
}
};
// 获取音频链接的key
export const getAudioUrlKey = (item: any) => {
if (item.url) {
return 'url';
} else if (item.audio_url) {
return 'audio_url';
} else if (item.old_content) {
return 'old_content';
} else if (item.content) {
return 'content';
}
};
......
import Lame from 'lamejs/src/js/Lame';
import Presets from 'lamejs/src/js/Presets';
import GainAnalysis from 'lamejs/src/js/GainAnalysis';
import QuantizePVT from 'lamejs/src/js/QuantizePVT';
import Quantize from 'lamejs/src/js/Quantize';
import Reservoir from 'lamejs/src/js/Reservoir';
import Takehiro from 'lamejs/src/js/Takehiro';
import MPEGMode from 'lamejs/src/js/MPEGMode';
import BitStream from 'lamejs/src/js/BitStream';
// import Lame from 'lamejs/src/js/Lame';
// import Presets from 'lamejs/src/js/Presets';
// import GainAnalysis from 'lamejs/src/js/GainAnalysis';
// import QuantizePVT from 'lamejs/src/js/QuantizePVT';
// import Quantize from 'lamejs/src/js/Quantize';
// import Reservoir from 'lamejs/src/js/Reservoir';
// import Takehiro from 'lamejs/src/js/Takehiro';
// import MPEGMode from 'lamejs/src/js/MPEGMode';
// import BitStream from 'lamejs/src/js/BitStream';
window.Lame = Lame;
window.Presets = Presets;
window.GainAnalysis = GainAnalysis;
window.QuantizePVT = QuantizePVT;
window.Quantize = Quantize;
window.Reservoir = Reservoir;
window.Takehiro = Takehiro;
window.MPEGMode = MPEGMode;
window.BitStream = BitStream;
// window.Lame = Lame;
// window.Presets = Presets;
// window.GainAnalysis = GainAnalysis;
// window.QuantizePVT = QuantizePVT;
// window.Quantize = Quantize;
// window.Reservoir = Reservoir;
// window.Takehiro = Takehiro;
// window.MPEGMode = MPEGMode;
// window.BitStream = BitStream;
......@@ -234,6 +234,10 @@ export const alyOssUpload = (
});
} else {
UploadErrorCallback(fileName);
writeLog({
name: '阿里云上传失败-res!=200 res!= ""',
value: res,
});
reject({
status: 'error',
response: '',
......@@ -242,6 +246,10 @@ export const alyOssUpload = (
})
.catch((e) => {
console.log(e);
writeLog({
name: 'tool aly upload error',
value: e,
});
reject({
status: 'error',
response: '',
......@@ -271,6 +279,27 @@ export const getFileSuffix = (file: any) => {
}
};
// 根据url获取文件后缀
export const getFileSuffixInUrl = (url: string) => {
let dotIndex = url.lastIndexOf('.');
if (dotIndex !== -1) {
let suffix = url.slice(dotIndex + 1, url.length).toLowerCase();
// 遇到第一个问号就暂停
if (suffix.indexOf('?') !== -1) {
let regex = /^.*(?=\?)/;
let match = suffix.match(regex);
// 匹配成功
if (match) {
return match[0];
}
return suffix;
}
return suffix;
} else {
return '';
}
};
// 二进制文件下载
export const downloadBlobFile = (blob: Blob, name: string = 'test') => {
// 创建下载链接
......
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