Commit 9dd61e5a by haojie

1

parent 942c15df
...@@ -59,13 +59,10 @@ const props = withDefaults( ...@@ -59,13 +59,10 @@ const props = withDefaults(
playId?: any; playId?: any;
progress: number; progress: number;
liveDetail: any; liveDetail: any;
eplay?: number;
mainVideoList: any[]; mainVideoList: any[];
loading: boolean; loading: boolean;
}>(), }>(),
{ {},
eplay: 0,
},
); );
const emit = defineEmits(['currentTime', 'playEnd', 'update:progress', 'update:playMainIndex', 'mainVideoListChange']); const emit = defineEmits(['currentTime', 'playEnd', 'update:progress', 'update:playMainIndex', 'mainVideoListChange']);
...@@ -266,16 +263,6 @@ watch( ...@@ -266,16 +263,6 @@ watch(
}, },
); );
// 主视频重新播放
watch(
() => props.eplay,
(v) => {
videoFirst.value[currentPlayMainIndex.value].currentTime = 0;
// 播放video
videoFirst.value[currentPlayMainIndex.value].play();
},
);
// 判断是否洗稿 // 判断是否洗稿
watch( watch(
() => props.liveDetail, () => props.liveDetail,
......
...@@ -83,6 +83,10 @@ ...@@ -83,6 +83,10 @@
color: #e0e0e0; color: #e0e0e0;
font-size: @size-14; font-size: @size-14;
font-weight: 700; font-weight: 700;
max-width: 70px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
& > * { & > * {
margin: 12px; margin: 12px;
......
...@@ -32,7 +32,7 @@ export default function () { ...@@ -32,7 +32,7 @@ export default function () {
if (res.code == 0) { if (res.code == 0) {
console.log('洗稿提交成功'); console.log('洗稿提交成功');
// 打开定时器 // 打开定时器
openConfuseInterval('1'); openConfuseInterval('');
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -2,7 +2,7 @@ import { computed, onBeforeUnmount, ref, watch } from 'vue'; ...@@ -2,7 +2,7 @@ import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { createLiveKeys, scriptTypeText } from '@/service/CreateLive'; import { createLiveKeys, scriptTypeText } from '@/service/CreateLive';
import { getLiveTtsCallback, createLiveTask, liveTts, liveTaskRegenerate } from '@/utils/api/userApi'; import { getLiveTtsCallback, createLiveTask, liveTts, liveTaskRegenerate } from '@/utils/api/userApi';
import { alyOssUpload, dimensionalConvert, isDev, show_message } from '@/utils/tool'; import { DataType, alyOssUpload, dimensionalConvert, isDev, show_message } from '@/utils/tool';
import { audioMerge, splitAudio } from '@/utils/audio'; import { audioMerge, splitAudio } from '@/utils/audio';
import { useLiveInfoSubmit } from '@/hooks/useStoreCommit'; import { useLiveInfoSubmit } from '@/hooks/useStoreCommit';
import { getUploadConfig, onUpdateLiveTask } from '@/service/Common'; import { getUploadConfig, onUpdateLiveTask } from '@/service/Common';
...@@ -110,16 +110,36 @@ export const processTextCallback = () => { ...@@ -110,16 +110,36 @@ export const processTextCallback = () => {
params.type_content = item[createLiveKeys.audioScriptList].map((audioScript: any) => { params.type_content = item[createLiveKeys.audioScriptList].map((audioScript: any) => {
let list = []; let list = [];
audioScript.data.forEach((it: any) => { audioScript.data.forEach((it: any) => {
let params = { let params: any = {
content: '', content: '',
old_content: '',
name: '',
}; };
if (typeof it === 'string') { if (typeof it === 'string') {
params.content = it; params.content = it;
params.old_content = it;
} else if (it.url) { } else if (it.url) {
params.content = it.url; params.content = it.url;
params.old_content = it.url;
} else { } else {
params.content = it.audio_url; params.content = it.audio_url;
params.old_content = it.audio_url;
}
if (typeof it !== 'string' && it.new_content) {
params.content = it.new_content;
params.uuid = it.uuid;
}
// 获取文件名
if (!DataType(it, 'string') && DataType(it, 'object')) {
if (it.name) {
params.name = it.name;
} else if (it.file && it.file.name) {
params.name = it.file.name;
}
} }
list.push(params); list.push(params);
}); });
return list; return list;
...@@ -211,10 +231,7 @@ export const processTextCallback = () => { ...@@ -211,10 +231,7 @@ export const processTextCallback = () => {
// 获取文件名 // 获取文件名
const getFileName = (file: any) => { const getFileName = (file: any) => {
if (!file.name) { return file.name ? file.name : v4();
return v4();
}
return file.name;
}; };
// 洗稿 // 洗稿
...@@ -233,11 +250,12 @@ export const processTextCallback = () => { ...@@ -233,11 +250,12 @@ export const processTextCallback = () => {
// }); // });
currentConfuseId.value = v4(); currentConfuseId.value = v4();
// 轮询拉取洗稿回调 // 轮询拉取洗稿回调
openConfuseInterval(`${userInfo.value.id}_${live_task_id.value}`); openConfuseInterval(`${userInfo.value.id}-${live_task_id.value}`);
}; };
// 阿里云上传成功回调 // 阿里云上传成功回调
const uploadSuccess = (name: string, url: string) => { const uploadSuccess = (name: string, url: string) => {
// console.log(url, '阿里云上传后的');
alyList.value.push([ alyList.value.push([
{ {
content: url, content: url,
...@@ -474,6 +492,7 @@ export const processTextCallback = () => { ...@@ -474,6 +492,7 @@ export const processTextCallback = () => {
loading, loading,
initNum, initNum,
currentSetp, currentSetp,
live_task_id,
openInterval, openInterval,
filterFiled, filterFiled,
initCreateStore, initCreateStore,
...@@ -484,5 +503,6 @@ export const processTextCallback = () => { ...@@ -484,5 +503,6 @@ export const processTextCallback = () => {
confuseList, confuseList,
currentStartConfuse, currentStartConfuse,
audioStart, audioStart,
uploadToAly,
}; };
}; };
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
:liveDetail="liveDetail" :liveDetail="liveDetail"
:video2="addVideo" :video2="addVideo"
:mainVideoList="mainVideoList" :mainVideoList="mainVideoList"
:eplay="eplay"
@playEnd="playEnd" @playEnd="playEnd"
@currentTime="currentTimeChange" @currentTime="currentTimeChange"
@mainVideoListChange="mainVideoListChange" @mainVideoListChange="mainVideoListChange"
...@@ -47,7 +46,6 @@ const userInfo = computed(() => store.getters['user/userInfo']); ...@@ -47,7 +46,6 @@ const userInfo = computed(() => store.getters['user/userInfo']);
const loading = ref(true); const loading = ref(true);
const progress = ref(0); const progress = ref(0);
const eplay = ref(0);
// 剩余多少时长时开始洗稿并获取下一个视频 // 剩余多少时长时开始洗稿并获取下一个视频
const esidueTime = 60 * 10; const esidueTime = 60 * 10;
...@@ -189,7 +187,7 @@ const submitConfuse = async () => { ...@@ -189,7 +187,7 @@ const submitConfuse = async () => {
// } // }
// 生成一个uid // 生成一个uid
currentConfuseId.value = v4(); currentConfuseId.value = v4();
openConfuseInterval(`${userInfo.value.id}_${liveDetail.value.id}`); openConfuseInterval(`${userInfo.value.id}-${liveDetail.value.id}`);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
......
...@@ -192,7 +192,7 @@ import TextScriptDialog from './TextScriptDialog.vue'; ...@@ -192,7 +192,7 @@ import TextScriptDialog from './TextScriptDialog.vue';
import ScriptTemplate from '@/components/ScriptTemplate.vue'; import ScriptTemplate from '@/components/ScriptTemplate.vue';
import Select from '@/components/Select.vue'; import Select from '@/components/Select.vue';
import SelectionPopup from '@/components/SelectionPopup.vue'; import SelectionPopup from '@/components/SelectionPopup.vue';
import { show_message, isDev } from '@/utils/tool'; import { show_message, isDev, ecursionDeepCopy } from '@/utils/tool';
import { createLiveKeys, scriptTypeList, scriptTypeText, scriptTypePhonetics } from '@/service/CreateLive'; import { createLiveKeys, scriptTypeList, scriptTypeText, scriptTypePhonetics } from '@/service/CreateLive';
import { useLiveInfoSubmit } from '@/hooks/useStoreCommit'; import { useLiveInfoSubmit } from '@/hooks/useStoreCommit';
import { getUploadConfig, getTonesList } from '@/service/Common'; import { getUploadConfig, getTonesList } from '@/service/Common';
...@@ -285,7 +285,7 @@ const currentOption = ref(scriptTypeText); ...@@ -285,7 +285,7 @@ const currentOption = ref(scriptTypeText);
const createUploadFile = (list: any[], oldList: any[]) => { const createUploadFile = (list: any[], oldList: any[]) => {
// 添加到数组中 // 添加到数组中
audioScriptList.value.push({ audioScriptList.value.push({
data: JSON.parse(JSON.stringify(oldList)), data: oldList,
}); });
// 提交到store // 提交到store
uploadChange(); uploadChange();
...@@ -448,6 +448,11 @@ const updateInfo = (info: any) => { ...@@ -448,6 +448,11 @@ const updateInfo = (info: any) => {
if (route.query.type == 'edit') { if (route.query.type == 'edit') {
if (type_content) { if (type_content) {
audioScriptList.value = type_content.map((item: any) => { audioScriptList.value = type_content.map((item: any) => {
let list = [];
item.forEach((it: any) => {
// 找到所有uuid一致的
// it.uuid
});
return { return {
data: item, data: item,
}; };
......
...@@ -73,10 +73,10 @@ import HomeSvg from '@/assets/svg/createLive/home.svg'; ...@@ -73,10 +73,10 @@ import HomeSvg from '@/assets/svg/createLive/home.svg';
import InteractSvg from '@/assets/svg/createLive/interact.svg'; import InteractSvg from '@/assets/svg/createLive/interact.svg';
import ScriptsSvg from '@/assets/svg/createLive/scripts.svg'; import ScriptsSvg from '@/assets/svg/createLive/scripts.svg';
import { computed, onBeforeMount, ref, onBeforeUnmount, onActivated } from 'vue'; import { computed, onBeforeMount, ref, onBeforeUnmount, onActivated } from 'vue';
import { getElBounding, show_message, isDev, DataType, dimensionalConvert } from '@/utils/tool'; import { getElBounding, show_message, isDev, DataType, dimensionalConvert, getDurationOfAudioFile } from '@/utils/tool';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { createLiveKeys, scriptTypeText, scriptTypePhonetics } from '@/service/CreateLive'; import { createLiveKeys, scriptTypeText, scriptTypePhonetics } from '@/service/CreateLive';
import { getLiveTaskInfo, createDrafts, getDraftsDetail, liveTts } from '@/utils/api/userApi'; import { getLiveTaskInfo, createDrafts, getDraftsDetail, liveTts, createLiveTask } from '@/utils/api/userApi';
import { useRoute, onBeforeRouteLeave } from 'vue-router'; import { useRoute, onBeforeRouteLeave } from 'vue-router';
import routerConfig from '@/router/tool'; import routerConfig from '@/router/tool';
import { onUpdateLiveTask } from '@/service/Common'; import { onUpdateLiveTask } from '@/service/Common';
...@@ -90,6 +90,7 @@ const { ...@@ -90,6 +90,7 @@ const {
loading, loading,
initNum, initNum,
currentSetp, currentSetp,
live_task_id,
audioStart, audioStart,
openInterval, openInterval,
filterFiled, filterFiled,
...@@ -97,11 +98,16 @@ const { ...@@ -97,11 +98,16 @@ const {
submitSuccessed, submitSuccessed,
submit, submit,
initCreateStore, initCreateStore,
uploadToAly,
} = processTextCallback(); } = processTextCallback();
const [commitInfo] = useLiveInfoSubmit(); const [commitInfo] = useLiveInfoSubmit();
// 音频切割时长
const audioSplitNum = 5 * 60;
const store = useStore(); const store = useStore();
const route = useRoute(); const route = useRoute();
// 离开页面前的query // 离开页面前的query
const currentQuery = ref({}); const currentQuery = ref({});
const liveImage = computed(() => store.getters['live/getLiveimage']); const liveImage = computed(() => store.getters['live/getLiveimage']);
...@@ -427,6 +433,58 @@ const onEditSave = async () => { ...@@ -427,6 +433,58 @@ const onEditSave = async () => {
} }
}; };
// 音频切割
const audioSplit = async () => {
for (let i = 0; i < createLiveInfo.value[createLiveKeys.audioScriptList].length; i++) {
let item = createLiveInfo.value[createLiveKeys.audioScriptList][i];
for (let j = 0; j < item.data.length; j++) {
let row = item.data[j];
if (row.file && row.file.raw) {
// 文件时长
let fileDuration = await getDurationOfAudioFile(row.file.raw);
console.log(fileDuration, '文件时长');
if (fileDuration > audioSplitNum) {
// 开始切割
let result = await splitAudio(row.file.raw, audioSplitNum);
if (result.length) {
// 上传阿里云
let alyList = await uploadToAly(result);
let list = [];
alyList.forEach((aly: any) => {
aly.forEach((alyRow: any) => {
list.push(alyRow.content);
});
});
// console.log(list, 'list');
// 一维数组
row.new_content = list.join('|');
row.uuid = v4();
}
}
}
}
}
};
// 音频提交
const audioSubmit = async () => {
try {
loading.value = true;
await audioSplit();
let params = filterFiled();
let res: any = await createLiveTask(params);
if (res.code == 0) {
console.log('创建成功-', res.data.id);
live_task_id.value = res.data.id;
submitSuccessed();
}
loading.value = false;
} catch (e) {
loading.value = false;
console.log(e);
}
};
const confirm = async () => { const confirm = async () => {
// 确定生成 // 确定生成
if (!liveName.value) { if (!liveName.value) {
...@@ -438,18 +496,8 @@ const confirm = async () => { ...@@ -438,18 +496,8 @@ const confirm = async () => {
// 提交并洗稿 // 提交并洗稿
submitTaskAndConfuse('create'); submitTaskAndConfuse('create');
} else { } else {
// 音频脚本 // 音频脚本提交
try { await audioSubmit();
loading.value = true;
let res = await submit();
if (res) {
submitSuccessed();
}
loading.value = false;
} catch (e) {
loading.value = false;
console.log(e);
}
} }
}; };
...@@ -504,7 +552,6 @@ onBeforeMount(() => { ...@@ -504,7 +552,6 @@ onBeforeMount(() => {
// 缓存进入 // 缓存进入
onActivated(() => { onActivated(() => {
enterPageEvent(); enterPageEvent();
// 测试 // 测试
// let list = [ // let list = [
// // 小文件 // // 小文件
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<div class="home-tool-bar"> <div class="home-tool-bar">
<CustomTabs v-model="currentTab" theme="dark2"> <CustomTabs v-model="currentTab" theme="dark2">
<CustomTabPanel label="数字人作品" name="1"> <CustomTabPanel label="数字人作品" name="1">
<MyDigtalPeople :reloadNum="reloadNum"></MyDigtalPeople> <MyDigtalPeople ref="myDigtalPeopleRef" :reloadNum="reloadNum"></MyDigtalPeople>
</CustomTabPanel> </CustomTabPanel>
<CustomTabPanel label="数字人草稿" name="2"> <DigitalPeopleDraft></DigitalPeopleDraft> </CustomTabPanel> <CustomTabPanel label="数字人草稿" name="2"> <DigitalPeopleDraft></DigitalPeopleDraft> </CustomTabPanel>
<template #rightComponent> <template #rightComponent>
...@@ -84,6 +84,8 @@ import { jumpToCreateLivePage } from '@/router/jump'; ...@@ -84,6 +84,8 @@ import { jumpToCreateLivePage } from '@/router/jump';
const router = useRouter(); const router = useRouter();
const myDigtalPeopleRef = ref(null);
// 当前tab栏 // 当前tab栏
const currentTab = ref('1'); const currentTab = ref('1');
// 弹窗状态 // 弹窗状态
...@@ -194,8 +196,9 @@ const getList = async () => { ...@@ -194,8 +196,9 @@ const getList = async () => {
}; };
onMounted(() => { onMounted(() => {
// // 获取我的数字人
getList(); getList();
console.log(myDigtalPeopleRef.value);
}); });
</script> </script>
......
...@@ -50,7 +50,6 @@ const mutations = { ...@@ -50,7 +50,6 @@ const mutations = {
}, },
setUserInfo(state: StateType, userInfo: UserInfo) { setUserInfo(state: StateType, userInfo: UserInfo) {
state.userInfo = {}; state.userInfo = {};
console.log(userInfo);
Object.assign(state.userInfo, userInfo); Object.assign(state.userInfo, userInfo);
}, },
// 修改用户信息中的某一项 // 修改用户信息中的某一项
......
...@@ -82,57 +82,6 @@ export async function audioMerge(filePaths) { ...@@ -82,57 +82,6 @@ export async function audioMerge(filePaths) {
} }
} }
// 切割音频文件
// export async function splitAudio(fileBlob: Blob, splitSize: number) {
// if (fileBlob.size < splitSize) {
// return [fileBlob];
// }
// try {
// const MAX_CHUNK_SIZE = splitSize;
// const newChunks = [];
// const asyncReadFile = (file, offset) => {
// return new Promise((resolve, reject) => {
// const reader = new FileReader();
// reader.onload = (event) => {
// const binaryData = event.target.result;
// const chunkName = v4();
// const binaryFile = new File([binaryData], chunkName, { type: file.type });
// resolve(binaryFile);
// };
// reader.onerror = () => {
// reject(new Error('File read error.'));
// };
// const chunk = file.slice(offset, offset + MAX_CHUNK_SIZE);
// reader.readAsArrayBuffer(chunk);
// });
// };
// for (const file of [fileBlob]) {
// const fileSize = file.size;
// let offset = 0;
// while (offset < fileSize) {
// const chunkSize = Math.min(MAX_CHUNK_SIZE, fileSize - offset);
// const binaryFile = await asyncReadFile(file, offset);
// newChunks.push(binaryFile);
// offset += chunkSize;
// }
// }
// console.log('切割后的文件', newChunks);
// return newChunks;
// } catch (e) {
// show_message('音频切割失败');
// }
// }
export const splitAudio = async (audioBlob: Blob, duration: number) => { export const splitAudio = async (audioBlob: Blob, duration: number) => {
const audioContext = new AudioContext(); const audioContext = new AudioContext();
const audioBufferList = []; const audioBufferList = [];
......
...@@ -162,6 +162,19 @@ export const deepCopy = (value: any) => { ...@@ -162,6 +162,19 @@ export const deepCopy = (value: any) => {
return JSON.parse(JSON.stringify(value)); return JSON.parse(JSON.stringify(value));
}; };
// 递归深拷贝
export const ecursionDeepCopy = (value: any) => {
// 创建一个新的目标对象或数组
let copy = Array.isArray(value) ? [] : {};
// 遍历原对象或数组的属性
for (let key in value) {
// 递归调用深拷贝函数复制每个属性的值
copy[key] = deepCopy(value[key]);
}
return copy;
};
// 阿里云上传 // 阿里云上传
export const alyOssUpload = ( export const alyOssUpload = (
config: any, config: any,
...@@ -339,3 +352,52 @@ export const randomIntFormList = (list: any[]) => { ...@@ -339,3 +352,52 @@ export const randomIntFormList = (list: any[]) => {
let index = randomInt(0, list.length - 1); let index = randomInt(0, list.length - 1);
return list[index]; return list[index];
}; };
// 循环耗时测试
export function timeComparison() {
let list = new Array(1000000000);
let start, end, i;
// 测试for循环的执行时间
start = performance.now();
for (i = 0; i < list.length; i++) {
let item = list[i];
}
end = performance.now();
console.log('for循环执行时间:' + (end - start) + ' 毫秒');
// 测试while循环的执行时间
start = performance.now();
i = 0;
while (i < list.length) {
let item = list[i];
i++;
}
end = performance.now();
console.log('while循环执行时间:' + (end - start) + ' 毫秒');
// 测试forEach的时间
start = performance.now();
list.forEach((item: any) => {
let it = item;
});
end = performance.now();
console.log('forEach循环执行时间:' + (end - start) + ' 毫秒');
}
// 获取音频文件的时长
export const getDurationOfAudioFile = (file: File) => {
console.log(file);
return new Promise((resolve, reject) => {
const audio = new Audio();
audio.src = URL.createObjectURL(file);
audio.onloadedmetadata = () => {
resolve(audio.duration);
};
audio.onerror = () => {
reject('无法获取音频文件的时长!');
};
});
};
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