Commit b6739667 by haojie

添加动作版本

parent 9f7df6f6
...@@ -145,3 +145,13 @@ export const videoAccept = 'mp4'; ...@@ -145,3 +145,13 @@ export const videoAccept = 'mp4';
// 音频切割间隔时长 // 音频切割间隔时长
export const audioSplitDuration = 300; export const audioSplitDuration = 300;
// 是否使用测试uuid
export const getTestUuid = () => {
let isTest = false;
if (isTest) {
return '8090ec74-5ad2-430a-ae8c-94755225ccdc';
} else {
return false;
}
};
...@@ -65,8 +65,7 @@ export default function () { ...@@ -65,8 +65,7 @@ export default function () {
} }
closeConfuseInterval(); closeConfuseInterval();
} else { } else {
console.log('洗稿还没有回调', id); console.log('洗稿还没有回调-useConfuse', id, res.data);
console.log(res.data);
} }
} catch (e) { } catch (e) {
writeLog({ writeLog({
......
...@@ -10,6 +10,7 @@ import { useRoute, useRouter } from 'vue-router'; ...@@ -10,6 +10,7 @@ import { useRoute, useRouter } from 'vue-router';
import routerConfig from '@/router/tool'; import routerConfig from '@/router/tool';
import useConfuse from '@/hooks/useConfuse'; import useConfuse from '@/hooks/useConfuse';
import { callPyjsInWindow, writeLog } from '@/utils/pyqt'; import { callPyjsInWindow, writeLog } from '@/utils/pyqt';
import { getTestUuid } from '@/constants/token';
// 轮询处理文本脚本语音生成回调 // 轮询处理文本脚本语音生成回调
export const processTextCallback = () => { export const processTextCallback = () => {
...@@ -43,8 +44,9 @@ export const processTextCallback = () => { ...@@ -43,8 +44,9 @@ export const processTextCallback = () => {
// 音调 // 音调
tone_id: item[createLiveKeys.textTones], tone_id: item[createLiveKeys.textTones],
content: list[i].content, content: list[i].content,
uuid: getTaskId(true), uuid: v4(),
id: i, id: i,
parent_uuid: currentConfuseId.value,
}; };
// 生成音频 // 生成音频
await liveTts(params); await liveTts(params);
...@@ -59,7 +61,7 @@ export const processTextCallback = () => { ...@@ -59,7 +61,7 @@ export const processTextCallback = () => {
() => confuseList.value, () => confuseList.value,
(v) => { (v) => {
if (v.length) { if (v.length) {
console.log('洗稿列表变化'); console.log('洗稿列表变化--useScript');
// 提交生成音频任务 // 提交生成音频任务
submitAudioTask(v); submitAudioTask(v);
} }
...@@ -210,11 +212,9 @@ export const processTextCallback = () => { ...@@ -210,11 +212,9 @@ export const processTextCallback = () => {
// 是洗稿任务 // 是洗稿任务
return currentConfuseId.value; return currentConfuseId.value;
} }
// 测试用 let testUuid = getTestUuid();
let isTest = true; if (testUuid) {
if (isTest) { return testUuid;
// uuid写死
return '';
} }
console.log('store uuid', createLiveInfo.value[createLiveKeys.scriptUuid]); console.log('store uuid', createLiveInfo.value[createLiveKeys.scriptUuid]);
return createLiveInfo.value[createLiveKeys.scriptUuid]; return createLiveInfo.value[createLiveKeys.scriptUuid];
...@@ -265,7 +265,6 @@ export const processTextCallback = () => { ...@@ -265,7 +265,6 @@ export const processTextCallback = () => {
data.audio_address && data.audio_address &&
(typeof data.task_id === 'string' || typeof data.task_id === 'number') (typeof data.task_id === 'string' || typeof data.task_id === 'number')
) { ) {
console.log(list, 'list');
let index = list.findIndex((it: any) => it.task_id == data.task_id); let index = list.findIndex((it: any) => it.task_id == data.task_id);
if (index !== -1) { if (index !== -1) {
list[index].audio_address = data.audio_address; list[index].audio_address = data.audio_address;
...@@ -306,6 +305,7 @@ export const processTextCallback = () => { ...@@ -306,6 +305,7 @@ export const processTextCallback = () => {
if (createLiveVersion === 'v1') { if (createLiveVersion === 'v1') {
await startConfuse(); await startConfuse();
} else if (createLiveVersion === 'v2') { } else if (createLiveVersion === 'v2') {
let testUuid = getTestUuid();
// 异步执行 // 异步执行
store.dispatch('asyncCreateLive/confuse', { store.dispatch('asyncCreateLive/confuse', {
user_id: userInfo.value.id, user_id: userInfo.value.id,
...@@ -313,7 +313,7 @@ export const processTextCallback = () => { ...@@ -313,7 +313,7 @@ export const processTextCallback = () => {
// 洗稿id // 洗稿id
task_id: `${userInfo.value.id}-${live_task_id.value}`, task_id: `${userInfo.value.id}-${live_task_id.value}`,
// 音频任务回调uid // 音频任务回调uid
audio_task_id: v4(), audio_task_id: testUuid ? testUuid : v4(),
createLiveInfo: ecursionDeepCopy(createLiveInfo.value), createLiveInfo: ecursionDeepCopy(createLiveInfo.value),
}); });
// //
......
...@@ -146,7 +146,8 @@ const submitAudioTask = async (list: any[]) => { ...@@ -146,7 +146,8 @@ const submitAudioTask = async (list: any[]) => {
// 音调 // 音调
tone_id: liveDetail.value.tone_id, tone_id: liveDetail.value.tone_id,
content: list[i].content, content: list[i].content,
uuid: currentConfuseId.value, uuid: v4(),
parent_uuid: currentConfuseId.value,
id: i, id: i,
}; };
// 生成音频 // 生成音频
......
...@@ -104,7 +104,7 @@ import CustomException from '@/utils/error'; ...@@ -104,7 +104,7 @@ import CustomException from '@/utils/error';
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { splitAudio } from '@/utils/audio'; import { splitAudio } from '@/utils/audio';
import { audioScriptVersion } from '@/service/CreateLive'; import { audioScriptVersion } from '@/service/CreateLive';
import { audioSplitDuration } from '@/constants/token'; import { audioSplitDuration, getTestUuid } from '@/constants/token';
const { const {
loading, loading,
initNum, initNum,
...@@ -118,9 +118,6 @@ const { ...@@ -118,9 +118,6 @@ const {
} = processTextCallback(); } = processTextCallback();
const [commitInfo] = useLiveInfoSubmit(); const [commitInfo] = useLiveInfoSubmit();
// 音频切割时长
const audioSplitNum = 5 * 60;
const store = useStore(); const store = useStore();
const route = useRoute(); const route = useRoute();
...@@ -444,7 +441,13 @@ const submitTaskAndConfuse = async (type: string) => { ...@@ -444,7 +441,13 @@ const submitTaskAndConfuse = async (type: string) => {
let index = newList.findIndex((it: any) => it.uuid == params.uuid); let index = newList.findIndex((it: any) => it.uuid == params.uuid);
if (index !== -1) { if (index !== -1) {
let list = JSON.parse(JSON.stringify(newList)); let list = JSON.parse(JSON.stringify(newList));
list[i].task_id = res.data.task_id; // 是否使用测试id
let testUuid = getTestUuid();
if (testUuid) {
list[i].task_id = 'ed71050141c74954ac779cfbb9dd9604';
} else {
list[i].task_id = res.data.task_id;
}
commitInfo({ commitInfo({
[createLiveKeys.textScriptList]: list, [createLiveKeys.textScriptList]: list,
}); });
...@@ -603,62 +606,67 @@ const audioConvert = async (type: string) => { ...@@ -603,62 +606,67 @@ const audioConvert = async (type: string) => {
// 音频切割v2 // 音频切割v2
const audioSplitV2 = async (type: string) => { const audioSplitV2 = async (type: string) => {
let list = createLiveInfo.value[createLiveKeys.audioScriptList]; try {
// 清空总次数 let list = createLiveInfo.value[createLiveKeys.audioScriptList];
audioSplitTaskTotal.value = 0; // 清空总次数
for (let i = 0; i < list.length; i++) { audioSplitTaskTotal.value = 0;
let item = list[i].audioList; for (let i = 0; i < list.length; i++) {
for (let j = 0; j < item.length; j++) { let item = list[i].audioList;
let row = item[j]; for (let j = 0; j < item.length; j++) {
if (row.children && row.children.length > 1) { let row = item[j];
// 编辑时没有修改参数 if (row.children && row.children.length > 1) {
continue; // 编辑时没有修改参数
} continue;
if ( }
row.duration && if (
row.duration > audioSplitNum && row.duration &&
row.content && row.duration > audioSplitDuration &&
row.content.indexOf('|') == -1 && row.content &&
row.old_content && row.content.indexOf('|') == -1 &&
!row.file?.raw row.old_content &&
) { !row.file?.raw
console.log('大于5分钟,开始下载文件'); ) {
// 没有文件时,下载 console.log('大于5分钟,开始下载文件');
let file = await getFile(row.old_content); // 没有文件时,下载
row.file = {}; let file = await getFile(row.old_content);
row.file.raw = file; row.file = {};
console.log(row.file); row.file.raw = file;
} console.log(row.file);
if (row.file && row.file.raw) { }
// 文件时长 if (row.file && row.file.raw) {
let fileDuration = await getDurationOfAudioFile(row.file.raw); // 文件时长
console.log(fileDuration, '文件时长'); let fileDuration = await getDurationOfAudioFile(row.file.raw);
if (fileDuration > audioSplitNum) { console.log(fileDuration, '文件时长');
// 通知python切割 if (fileDuration > audioSplitDuration) {
callPyjsInWindow('splitAudio', { // 通知python切割
url: getAudioUrl(row), callPyjsInWindow('splitAudio', {
duration: audioSplitDuration, url: getAudioUrl(row),
id: route.query.id, duration: audioSplitDuration,
type: type, id: route.query.id,
}); type: type,
// 更新状态 });
row.py_remove = true; // 更新状态
row.py_split_status = false; row.py_remove = true;
// 统计总次数 row.py_split_status = false;
audioSplitTaskTotal.value += 1; // 统计总次数
audioSplitTaskTotal.value += 1;
}
} }
} }
} }
} if (audioSplitTaskTotal.value === 0) {
if (audioSplitTaskTotal.value === 0) { console.log('没有要切割的,直接提交');
// 没有要切割的,直接提交 // 没有要切割的,直接提交
if (type == 'create') { if (type == 'create') {
// 创建 // 创建
audioScriptLiveTaskSubmit(); audioScriptLiveTaskSubmit();
} else { } else {
// 更新 // 更新
audioScriptEditSubmit(); audioScriptEditSubmit();
}
} }
} catch (e) {
console.log(e, '音频切割v2');
} }
}; };
......
...@@ -13,6 +13,7 @@ import store from '@/store'; ...@@ -13,6 +13,7 @@ import store from '@/store';
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { writeLog } from '@/utils/pyqt'; import { writeLog } from '@/utils/pyqt';
import { getDurationOfAudioFile } from '@/utils/audio'; import { getDurationOfAudioFile } from '@/utils/audio';
import { getTestUuid } from '@/constants/token';
/** /**
* 创建直播的版本 * 创建直播的版本
...@@ -136,49 +137,57 @@ export const mergeSameAudio = (content: any[]) => { ...@@ -136,49 +137,57 @@ export const mergeSameAudio = (content: any[]) => {
export const onRewriteCallback = async (id: string) => { export const onRewriteCallback = async (id: string) => {
return new Promise<any[]>((resolve) => { return new Promise<any[]>((resolve) => {
let interval = null; let interval = null;
console.log('开启轮询,洗稿回调'); let status = true;
// 关闭定时器 // 关闭定时器
const closeConfuseInterval = () => { const closeConfuseInterval = async () => {
window.clearInterval(interval); window.clearInterval(interval);
clearInterval(interval); clearInterval(interval);
interval = null; interval = null;
status = false;
console.log('洗稿定时器已关闭');
}; };
// 回调方法 // 回调方法
const currentStartConfuseBack = async (id: any) => { const currentStartConfuseBack = async (id: any) => {
try { if (status) {
let res: any = await liveContentRegenerateCallback({ try {
task_id: id, let res: any = await liveContentRegenerateCallback({
}); task_id: id,
if (isDev()) { });
// if (isDev()) {
res.data = [ //
{ res.data = [
content: `大家好!欢迎来到今天的直播!我是你们的主持人,今天我将为大家带来一场精彩的直播节目`, {
}, content: `大家好!欢迎来到今天的直播!我是你们的主持人,今天我将为大家带来一场精彩的直播节目`,
]; },
} ];
if (res.code == 0 && res.data.length) { }
console.log('洗稿回调成功'); if (res.code == 0 && res.data.length) {
closeConfuseInterval(); console.log('洗稿回调成功', res.data);
// 返回值 await closeConfuseInterval();
resolve(res.data); console.log('resolve');
} else { // 返回值
console.log('洗稿还没有回调', id); resolve(res.data);
console.log(res.data); } else {
console.log('洗稿还没有回调-service-createLive', id, res.data);
}
} catch (e) {
writeLog({
name: 'service onRewriteCallback.currentStartConfuseBack error',
value: e,
});
console.log(e);
} }
} catch (e) { } else {
writeLog({ console.log('还在回调,关闭定时器');
name: 'service onRewriteCallback.currentStartConfuseBack error', await closeConfuseInterval();
value: e,
});
console.log(e);
} }
}; };
// 打开定时器 // 打开定时器
interval = window.setInterval(() => { interval = window.setInterval(() => {
console.log('获取洗稿回调,打开定时器');
currentStartConfuseBack(id); currentStartConfuseBack(id);
}, 3000); }, 3000);
}); });
...@@ -194,7 +203,8 @@ export const submitAudioTask = async (list: any[], item: any, uuid: string) => { ...@@ -194,7 +203,8 @@ export const submitAudioTask = async (list: any[], item: any, uuid: string) => {
// 音调 // 音调
tone_id: item[createLiveKeys.textTones], tone_id: item[createLiveKeys.textTones],
content: list[i].content, content: list[i].content,
uuid: uuid, uuid: v4(),
parent_uuid: uuid,
id: i, id: i,
}; };
// 生成音频 // 生成音频
...@@ -289,11 +299,13 @@ export const filterFiled = (item: any, type: string = '') => { ...@@ -289,11 +299,13 @@ export const filterFiled = (item: any, type: string = '') => {
} else { } else {
// 切割后的音频格式 // 切割后的音频格式
const audioConversion = (list: any[]) => { const audioConversion = (list: any[]) => {
return list let content: any = list.map((child: any) => {
.map((child: any) => { return child.url;
return child.audio_url; });
}) console.log(content, '合并前的数组content');
.join('|'); let str = content.join('|');
console.log(str, '合并后的str');
return str;
}; };
// 音频 // 音频
params.type_content = item[createLiveKeys.audioScriptList].map((audioScript: any) => { params.type_content = item[createLiveKeys.audioScriptList].map((audioScript: any) => {
...@@ -328,9 +340,10 @@ export const filterFiled = (item: any, type: string = '') => { ...@@ -328,9 +340,10 @@ export const filterFiled = (item: any, type: string = '') => {
} else { } else {
// 获取编辑状态下的content // 获取编辑状态下的content
if (it.children && it.children.length > 1) { if (it.children && it.children.length > 1) {
console.log(it.children, 'it.children,编辑状态下的参数');
// 修改content // 修改content
params.content = audioConversion(it.children); params.content = audioConversion(it.children);
params.old_content = it.audio_url; params.old_content = getAudioUrl(it);
} else { } else {
// 创建 // 创建
if (typeof it === 'string') { if (typeof it === 'string') {
...@@ -524,6 +537,8 @@ export const getAudioCallback = (audio_task_id: string, len: number, liveInfo: a ...@@ -524,6 +537,8 @@ export const getAudioCallback = (audio_task_id: string, len: number, liveInfo: a
// 提交 // 提交
await regenerate(list, liveInfo, live_id); await regenerate(list, liveInfo, live_id);
} }
} else {
console.log('音频还没有回调,async', res.data);
} }
} }
} catch (e) { } catch (e) {
......
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