Commit b6739667 by haojie

添加动作版本

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