Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
live-management-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
live-management-web
Commits
f21881b9
Commit
f21881b9
authored
Aug 11, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步洗稿
parent
5e4e82bd
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
615 additions
and
226 deletions
+615
-226
src/hooks/useConfuse.ts
+9
-0
src/hooks/useScript.ts
+49
-209
src/pages/InteractiveResponse/index.vue
+5
-0
src/pages/OnlyVideoLive/index.vue
+22
-1
src/pages/createLive/index.vue
+18
-6
src/service/Common.ts
+88
-1
src/service/CreateLive.ts
+317
-1
src/store/index.ts
+2
-0
src/store/modules/asyncCreateLive.ts
+52
-0
src/utils/audio.ts
+5
-2
src/utils/otherRequest.ts
+10
-3
src/utils/pyqt.ts
+11
-0
src/utils/request.ts
+6
-2
src/utils/tool.ts
+5
-0
src/utils/upLoadRequest.ts
+16
-1
No files found.
src/hooks/useConfuse.ts
View file @
f21881b9
import
{
liveContentRegenerate
,
liveContentRegenerateCallback
}
from
'@/utils/api/userApi'
;
import
{
liveContentRegenerate
,
liveContentRegenerateCallback
}
from
'@/utils/api/userApi'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
import
{
onBeforeUnmount
,
ref
}
from
'vue'
;
import
{
onBeforeUnmount
,
ref
}
from
'vue'
;
export
default
function
()
{
export
default
function
()
{
...
@@ -34,6 +35,10 @@ export default function () {
...
@@ -34,6 +35,10 @@ export default function () {
openConfuseInterval
(
''
);
openConfuseInterval
(
''
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'old 洗稿提交'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -53,6 +58,10 @@ export default function () {
...
@@ -53,6 +58,10 @@ export default function () {
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'old 洗稿回调'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/hooks/useScript.ts
View file @
f21881b9
import
{
computed
,
onBeforeUnmount
,
ref
,
watch
}
from
'vue'
;
import
{
computed
,
onBeforeUnmount
,
ref
,
watch
}
from
'vue'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
import
{
createLiveKeys
,
scriptTypeText
}
from
'@/service/CreateLive'
;
import
{
createLiveKeys
,
createLiveVersion
,
filterFiled
}
from
'@/service/CreateLive'
;
import
{
getLiveTtsCallback
,
createLiveTask
,
liveTts
,
liveTaskRegenerate
}
from
'@/utils/api/userApi'
;
import
{
getLiveTtsCallback
,
createLiveTask
,
liveTts
,
liveTaskRegenerate
}
from
'@/utils/api/userApi'
;
import
{
DataType
,
alyOssUpload
,
dimensionalConvert
,
isDev
,
show_message
}
from
'@/utils/tool'
;
import
{
ecursionDeepCopy
,
isDev
,
show_message
}
from
'@/utils/tool'
;
import
{
audioMerge
,
splitAudio
}
from
'@/utils/audio'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
getUploadConfig
,
onUpdateLiveTask
}
from
'@/service/Common'
;
import
{
onUpdateLiveTask
,
audioStart
,
uploadToAly
}
from
'@/service/Common'
;
import
{
v4
}
from
'uuid'
;
import
{
v4
}
from
'uuid'
;
import
{
useRoute
,
useRouter
}
from
'vue-router'
;
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
CustomException
from
'@/utils/error'
;
import
CustomException
from
'@/utils/error'
;
import
{
callPyjsInWindow
}
from
'@/utils/pyqt'
;
import
{
callPyjsInWindow
,
writeLog
}
from
'@/utils/pyqt'
;
// 轮询处理文本脚本语音生成回调
// 轮询处理文本脚本语音生成回调
export
const
processTextCallback
=
()
=>
{
export
const
processTextCallback
=
()
=>
{
...
@@ -34,9 +33,7 @@ export const processTextCallback = () => {
...
@@ -34,9 +33,7 @@ export const processTextCallback = () => {
// 文字转音频轮询
// 文字转音频轮询
const
interval
=
ref
(
null
);
const
interval
=
ref
(
null
);
const
createLiveInfo
=
computed
(()
=>
store
.
getters
[
'live/getLiveInfo'
]);
const
createLiveInfo
=
computed
(()
=>
store
.
getters
[
'live/getLiveInfo'
]);
const
liveName
=
computed
(()
=>
store
.
getters
[
'live/getName'
]);
const
userInfo
=
computed
(()
=>
store
.
getters
[
'user/userInfo'
]);
const
userInfo
=
computed
(()
=>
store
.
getters
[
'user/userInfo'
]);
const
alyList
=
ref
([]);
const
submitAudioTask
=
async
(
list
:
any
[])
=>
{
const
submitAudioTask
=
async
(
list
:
any
[])
=>
{
let
item
=
createLiveInfo
.
value
;
let
item
=
createLiveInfo
.
value
;
...
@@ -69,127 +66,9 @@ export const processTextCallback = () => {
...
@@ -69,127 +66,9 @@ export const processTextCallback = () => {
},
},
);
);
// 提交时过滤必要的字段
// 获取createLiveInfo
const
filterFiled
=
(
type
:
string
=
''
)
=>
{
const
getCreateLiveInfo
=
()
=>
{
let
item
=
createLiveInfo
.
value
;
return
createLiveInfo
.
value
;
// 过滤必须字段
let
params
:
any
=
{};
params
.
name
=
liveName
.
value
;
// 数字人id
params
.
digital_man_id
=
item
[
createLiveKeys
.
id
];
// 是否洗稿
params
.
is_disorganize
=
item
[
createLiveKeys
.
isDisorganize
];
// 脚本类型
params
.
type
=
item
[
createLiveKeys
.
scriptType
];
// 脚本内容
if
(
item
[
createLiveKeys
.
scriptType
]
==
scriptTypeText
)
{
// 文本
params
.
type_content
=
item
[
createLiveKeys
.
textScriptValue
];
// 转换格式
// 先二维转一维
params
.
type_content
=
dimensionalConvert
(
params
.
type_content
);
let
list
=
[];
params
.
type_content
.
forEach
((
item
:
any
)
=>
{
list
.
push
([
item
]);
});
params
.
type_content
=
list
;
console
.
log
(
params
.
type_content
,
'文本 type_content'
);
// 音色id
params
.
phonetic_timbres_id
=
item
[
createLiveKeys
.
textSoundColor
];
// 文本内容--先转一维数组
let
newList
=
dimensionalConvert
(
item
[
createLiveKeys
.
textScriptList
]);
params
.
content
=
newList
.
map
((
row
:
any
)
=>
{
return
{
title
:
row
.
title
,
content
:
row
.
content
,
};
});
}
else
{
// 切割后的音频格式
const
audioConversion
=
(
list
:
any
[])
=>
{
return
list
.
map
((
child
:
any
)
=>
{
return
child
.
audio_url
;
})
.
join
(
'|'
);
};
// 音频
params
.
type_content
=
item
[
createLiveKeys
.
audioScriptList
].
map
((
audioScript
:
any
)
=>
{
let
list
=
[];
audioScript
.
data
.
forEach
((
it
:
any
)
=>
{
let
params
:
any
=
{
content
:
''
,
old_content
:
''
,
name
:
''
,
uuid
:
v4
(),
duration
:
0
,
};
if
(
it
.
duration
)
{
params
.
duration
=
parseInt
(
it
.
duration
);
}
// 草稿类型的
if
(
type
==
'edit_drafts'
)
{
if
(
it
.
children
&&
it
.
children
.
length
>
1
)
{
// 有切割的
params
.
content
=
audioConversion
(
it
.
children
);
}
if
(
it
.
old_content
)
{
params
.
old_content
=
it
.
old_content
;
}
else
if
(
it
.
url
)
{
params
.
old_content
=
it
.
url
;
}
if
(
it
.
content
)
{
params
.
content
=
it
.
content
;
}
else
if
(
it
.
url
)
{
params
.
content
=
it
.
url
;
}
}
else
{
// 获取编辑状态下的content
if
(
it
.
children
&&
it
.
children
.
length
>
1
)
{
// 修改content
params
.
content
=
audioConversion
(
it
.
children
);
params
.
old_content
=
it
.
audio_url
;
}
else
{
if
(
typeof
it
===
'string'
)
{
params
.
content
=
it
;
params
.
old_content
=
it
;
}
else
if
(
it
.
url
)
{
params
.
content
=
it
.
url
;
params
.
old_content
=
it
.
url
;
}
else
{
params
.
content
=
it
.
audio_url
;
params
.
old_content
=
it
.
audio_url
;
}
}
}
// 切割后的
if
(
typeof
it
!==
'string'
&&
it
.
new_content
)
{
params
.
content
=
it
.
new_content
;
}
// 获取文件名
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
);
});
return
list
;
});
console
.
log
(
params
.
type_content
,
'音频 type_content'
);
// 音色id
params
.
phonetic_timbres_id
=
item
[
createLiveKeys
.
phoneticsSoundColor
];
}
// 音调id
params
.
tone_id
=
item
[
createLiveKeys
.
textTones
];
// 互动库
params
.
interaction_ids
=
item
[
createLiveKeys
.
interactiveLibrary
];
return
params
;
};
};
// 提交后的初始化操作
// 提交后的初始化操作
...
@@ -214,15 +93,19 @@ export const processTextCallback = () => {
...
@@ -214,15 +93,19 @@ export const processTextCallback = () => {
const
submit
=
async
(
type
:
string
=
'create'
)
=>
{
const
submit
=
async
(
type
:
string
=
'create'
)
=>
{
if
(
type
===
'create'
)
{
if
(
type
===
'create'
)
{
try
{
try
{
let
res
:
any
=
await
createLiveTask
(
filterFiled
());
let
res
:
any
=
await
createLiveTask
(
filterFiled
(
getCreateLiveInfo
()
));
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
console
.
log
(
'提交的参数'
,
JSON
.
stringify
(
filterFiled
()));
console
.
log
(
'提交的参数'
,
JSON
.
stringify
(
filterFiled
(
getCreateLiveInfo
()
)));
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
live_task_id
.
value
=
res
.
data
.
id
;
live_task_id
.
value
=
res
.
data
.
id
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'创建直播失败'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
return
false
;
return
false
;
}
}
...
@@ -230,7 +113,7 @@ export const processTextCallback = () => {
...
@@ -230,7 +113,7 @@ export const processTextCallback = () => {
// 更新
// 更新
console
.
log
(
'更新'
);
console
.
log
(
'更新'
);
try
{
try
{
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
loading
.
value
=
true
;
loading
.
value
=
true
;
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
if
(
res
)
{
if
(
res
)
{
...
@@ -245,6 +128,10 @@ export const processTextCallback = () => {
...
@@ -245,6 +128,10 @@ export const processTextCallback = () => {
}
}
loading
.
value
=
false
;
loading
.
value
=
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'更新直播失败'
,
value
:
e
,
});
loading
.
value
=
false
;
loading
.
value
=
false
;
console
.
log
(
e
);
console
.
log
(
e
);
}
}
...
@@ -267,11 +154,6 @@ export const processTextCallback = () => {
...
@@ -267,11 +154,6 @@ export const processTextCallback = () => {
currentSetp
.
value
=
1
;
currentSetp
.
value
=
1
;
};
};
// 获取文件名
const
getFileName
=
(
file
:
any
)
=>
{
return
file
.
name
?
file
.
name
:
v4
();
};
// 洗稿
// 洗稿
const
startConfuse
=
async
()
=>
{
const
startConfuse
=
async
()
=>
{
// currentConfuseId.value = v4();
// currentConfuseId.value = v4();
...
@@ -291,81 +173,10 @@ export const processTextCallback = () => {
...
@@ -291,81 +173,10 @@ export const processTextCallback = () => {
openConfuseInterval
(
`
${
userInfo
.
value
.
id
}
-
${
live_task_id
.
value
}
`
);
openConfuseInterval
(
`
${
userInfo
.
value
.
id
}
-
${
live_task_id
.
value
}
`
);
};
};
// 阿里云上传成功回调
const
uploadSuccess
=
(
name
:
string
,
url
:
string
)
=>
{
// console.log(url, '阿里云上传后的');
alyList
.
value
.
push
([
{
content
:
url
,
},
]);
};
// 循环上传阿里云
const
uploadToAly
=
async
(
fileList
:
File
[])
=>
{
// 每次上传前清空数组
alyList
.
value
=
[];
console
.
log
(
'任务数'
);
console
.
log
(
fileList
.
length
);
// 获取阿里云配置
let
config
=
await
getUploadConfig
();
for
(
let
i
=
0
;
i
<
fileList
.
length
;
i
++
)
{
let
file
=
fileList
[
i
];
let
retryNum
=
0
;
while
(
true
)
{
if
(
retryNum
>=
5
)
{
console
.
log
(
'音频块已经重试5次,跳过'
);
break
;
}
if
(
retryNum
)
{
config
=
await
getUploadConfig
();
}
try
{
// 上传阿里云
await
alyOssUpload
(
config
,
file
,
uploadSuccess
,
()
=>
false
,
getFileName
(
file
));
}
catch
(
e
)
{
if
(
e
&&
e
.
status
==
'error'
)
{
// 重新上传
console
.
log
(
'重新上传'
);
retryNum
+=
1
;
continue
;
}
}
break
;
}
}
// 上传完毕
return
alyList
.
value
;
};
// 音频合并切割
const
audioStart
=
async
(
list
:
any
[],
dimensional
:
boolean
=
true
)
=>
{
let
file
=
await
audioMerge
(
list
);
if
(
file
)
{
// 开始切割
let
split_list
=
await
splitAudio
(
file
,
300
);
// 合并后的文件上传
if
(
split_list
&&
split_list
.
length
)
{
let
result
=
await
uploadToAly
(
split_list
);
console
.
log
(
'上传完毕'
);
// 是否一维数组
if
(
dimensional
)
{
console
.
log
(
result
);
return
result
;
}
else
{
console
.
log
([
result
]);
return
[
result
];
}
}
}
else
{
console
.
log
(
'没有文件'
);
}
};
// 重新生成直播
// 重新生成直播
const
regenerate
=
async
(
list
:
any
[],
successCallback
:
boolean
)
=>
{
const
regenerate
=
async
(
list
:
any
[],
successCallback
:
boolean
)
=>
{
try
{
try
{
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
params
.
type_content
=
list
;
params
.
type_content
=
list
;
let
res
:
any
=
await
liveTaskRegenerate
(
live_task_id
.
value
,
params
);
let
res
:
any
=
await
liveTaskRegenerate
(
live_task_id
.
value
,
params
);
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
...
@@ -376,6 +187,10 @@ export const processTextCallback = () => {
...
@@ -376,6 +187,10 @@ export const processTextCallback = () => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'old 重新生成直播-error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -463,9 +278,26 @@ export const processTextCallback = () => {
...
@@ -463,9 +278,26 @@ export const processTextCallback = () => {
});
});
// 提交
// 提交
await
submit
(
type
);
await
submit
(
type
);
// 需要洗稿
// 需要洗稿
if
(
createLiveInfo
.
value
[
createLiveKeys
.
isDisorganize
])
{
if
(
createLiveInfo
.
value
[
createLiveKeys
.
isDisorganize
])
{
if
(
createLiveVersion
===
'v1'
)
{
await
startConfuse
();
await
startConfuse
();
}
else
if
(
createLiveVersion
===
'v2'
)
{
// 异步执行
store
.
dispatch
(
'asyncCreateLive/confuse'
,
{
user_id
:
userInfo
.
value
.
id
,
live_task_id
:
live_task_id
.
value
,
// 洗稿id
task_id
:
`
${
userInfo
.
value
.
id
}
-
${
live_task_id
.
value
}
`
,
// 音频任务回调uid
audio_task_id
:
v4
(),
createLiveInfo
:
ecursionDeepCopy
(
createLiveInfo
.
value
),
});
//
loading
.
value
=
false
;
submitSuccessed
();
}
}
else
{
}
else
{
console
.
log
(
'不用洗稿'
);
console
.
log
(
'不用洗稿'
);
loading
.
value
=
false
;
loading
.
value
=
false
;
...
@@ -483,6 +315,10 @@ export const processTextCallback = () => {
...
@@ -483,6 +315,10 @@ export const processTextCallback = () => {
if
(
data
&&
data
.
audio_address
)
{
if
(
data
&&
data
.
audio_address
)
{
audio_list
.
push
(
data
.
audio_address
);
audio_list
.
push
(
data
.
audio_address
);
}
else
{
}
else
{
writeLog
({
naem
:
'useScript-洗稿缺少参数'
,
value
:
data
,
});
show_message
(
'洗稿缺少参数'
);
show_message
(
'洗稿缺少参数'
);
}
}
});
});
...
@@ -499,6 +335,10 @@ export const processTextCallback = () => {
...
@@ -499,6 +335,10 @@ export const processTextCallback = () => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'useScript getTaskStatus-error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -531,7 +371,6 @@ export const processTextCallback = () => {
...
@@ -531,7 +371,6 @@ export const processTextCallback = () => {
currentSetp
,
currentSetp
,
live_task_id
,
live_task_id
,
openInterval
,
openInterval
,
filterFiled
,
initCreateStore
,
initCreateStore
,
submit
,
submit
,
submitSuccessed
,
submitSuccessed
,
...
@@ -541,5 +380,6 @@ export const processTextCallback = () => {
...
@@ -541,5 +380,6 @@ export const processTextCallback = () => {
currentStartConfuse
,
currentStartConfuse
,
audioStart
,
audioStart
,
uploadToAly
,
uploadToAly
,
getCreateLiveInfo
,
};
};
};
};
src/pages/InteractiveResponse/index.vue
View file @
f21881b9
...
@@ -14,6 +14,7 @@ import { useRoute } from 'vue-router';
...
@@ -14,6 +14,7 @@ import { useRoute } from 'vue-router';
import
{
callPyjsInWindow
,
injectWindow
}
from
'@/utils/pyqt'
;
import
{
callPyjsInWindow
,
injectWindow
}
from
'@/utils/pyqt'
;
import
{
getliveTaskReply
,
getUserCookie
}
from
'@/utils/api/userApi'
;
import
{
getliveTaskReply
,
getUserCookie
}
from
'@/utils/api/userApi'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
// 互动回复
// 互动回复
...
@@ -155,6 +156,10 @@ const mergeCallback = (params: any) => {
...
@@ -155,6 +156,10 @@ const mergeCallback = (params: any) => {
addVideo
.
value
=
params
.
add_video
;
addVideo
.
value
=
params
.
add_video
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'mergeCallback error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/pages/OnlyVideoLive/index.vue
View file @
f21881b9
...
@@ -32,6 +32,7 @@ import useConfuse from '@/hooks/useConfuse';
...
@@ -32,6 +32,7 @@ import useConfuse from '@/hooks/useConfuse';
import
{
CONFUSE_STATUS
}
from
'@/service/Live'
;
import
{
CONFUSE_STATUS
}
from
'@/service/Live'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
scriptTypeText
}
from
'@/service/CreateLive'
;
import
{
scriptTypeText
}
from
'@/service/CreateLive'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
const
{
currentConfuseId
,
confuseList
,
currentStartConfuse
,
openConfuseInterval
}
=
useConfuse
();
const
{
currentConfuseId
,
confuseList
,
currentStartConfuse
,
openConfuseInterval
}
=
useConfuse
();
const
{
openInterval
:
confuseInterval
}
=
processTextCallback
();
const
{
openInterval
:
confuseInterval
}
=
processTextCallback
();
...
@@ -375,6 +376,10 @@ const getLive = async () => {
...
@@ -375,6 +376,10 @@ const getLive = async () => {
addVideoList
.
value
=
addVideoList
.
value
.
concat
(
res
.
data
);
addVideoList
.
value
=
addVideoList
.
value
.
concat
(
res
.
data
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'getliveTaskReply 获取直播互动失败'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -395,6 +400,10 @@ const regenerate = async (list: any[]) => {
...
@@ -395,6 +400,10 @@ const regenerate = async (list: any[]) => {
console
.
log
(
'重新生成直播,已提交'
);
console
.
log
(
'重新生成直播,已提交'
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'only live regenerate error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -497,6 +506,10 @@ const getDetail = async (type: string = '') => {
...
@@ -497,6 +506,10 @@ const getDetail = async (type: string = '') => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'获取直播链接失败'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -523,7 +536,11 @@ const submitVideo = () => {
...
@@ -523,7 +536,11 @@ const submitVideo = () => {
show_message
(
'empty-1 py'
);
show_message
(
'empty-1 py'
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
show_message
(
e
.
message
);
console
.
log
(
e
);
writeLog
({
name
:
'only submitVideo error'
,
value
:
e
,
});
}
}
};
};
...
@@ -575,6 +592,10 @@ const mergeCallback = (params: any) => {
...
@@ -575,6 +592,10 @@ const mergeCallback = (params: any) => {
console
.
log
(
params
);
console
.
log
(
params
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'only mergeCallback error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/pages/createLive/index.vue
View file @
f21881b9
...
@@ -83,12 +83,12 @@ import {
...
@@ -83,12 +83,12 @@ import {
getFile
,
getFile
,
}
from
'@/utils/tool'
;
}
from
'@/utils/tool'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
import
{
createLiveKeys
,
scriptTypeText
,
scriptTypePhonetics
,
mergeSameAudio
}
from
'@/service/CreateLive'
;
import
{
createLiveKeys
,
scriptTypeText
,
scriptTypePhonetics
,
mergeSameAudio
,
filterFiled
}
from
'@/service/CreateLive'
;
import
{
getLiveTaskInfo
,
createDrafts
,
getDraftsDetail
,
liveTts
,
createLiveTask
}
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'
;
import
{
callPyjsInWindow
}
from
'@/utils/pyqt'
;
import
{
callPyjsInWindow
,
writeLog
}
from
'@/utils/pyqt'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
CustomException
from
'@/utils/error'
;
import
CustomException
from
'@/utils/error'
;
...
@@ -101,7 +101,7 @@ const {
...
@@ -101,7 +101,7 @@ const {
live_task_id
,
live_task_id
,
audioStart
,
audioStart
,
openInterval
,
openInterval
,
filterFiled
,
getCreateLiveInfo
,
submitSuccessed
,
submitSuccessed
,
uploadToAly
,
uploadToAly
,
}
=
processTextCallback
();
}
=
processTextCallback
();
...
@@ -275,6 +275,10 @@ const getEditInfo = async (id: any, type: string) => {
...
@@ -275,6 +275,10 @@ const getEditInfo = async (id: any, type: string) => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive getEditInfo error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -356,7 +360,7 @@ const onSave = () => {
...
@@ -356,7 +360,7 @@ const onSave = () => {
// 保存为草稿
// 保存为草稿
const
onSaveDrafts
=
async
()
=>
{
const
onSaveDrafts
=
async
()
=>
{
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
try
{
try
{
loading
.
value
=
true
;
loading
.
value
=
true
;
let
res
:
any
=
await
createDrafts
(
params
);
let
res
:
any
=
await
createDrafts
(
params
);
...
@@ -379,7 +383,7 @@ const editAudioSave = async () => {
...
@@ -379,7 +383,7 @@ const editAudioSave = async () => {
try
{
try
{
loading
.
value
=
true
;
loading
.
value
=
true
;
await
audioSplit
();
await
audioSplit
();
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
if
(
res
)
{
if
(
res
)
{
if
(
route
.
query
.
type
===
'edit'
)
{
if
(
route
.
query
.
type
===
'edit'
)
{
...
@@ -392,6 +396,10 @@ const editAudioSave = async () => {
...
@@ -392,6 +396,10 @@ const editAudioSave = async () => {
}
}
loading
.
value
=
false
;
loading
.
value
=
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive editAudioSave error'
,
value
:
e
,
});
loading
.
value
=
false
;
loading
.
value
=
false
;
console
.
log
(
e
);
console
.
log
(
e
);
}
}
...
@@ -508,7 +516,7 @@ const audioSubmit = async () => {
...
@@ -508,7 +516,7 @@ const audioSubmit = async () => {
if
(
route
.
query
.
type
==
'edit_drafts'
)
{
if
(
route
.
query
.
type
==
'edit_drafts'
)
{
type
=
'edit_drafts'
;
type
=
'edit_drafts'
;
}
}
let
params
=
filterFiled
(
type
);
let
params
=
filterFiled
(
getCreateLiveInfo
(),
type
);
let
res
:
any
=
await
createLiveTask
(
params
);
let
res
:
any
=
await
createLiveTask
(
params
);
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
...
@@ -517,6 +525,10 @@ const audioSubmit = async () => {
...
@@ -517,6 +525,10 @@ const audioSubmit = async () => {
}
}
loading
.
value
=
false
;
loading
.
value
=
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive audioSubmit error'
,
value
:
e
,
});
loading
.
value
=
false
;
loading
.
value
=
false
;
console
.
log
(
e
);
console
.
log
(
e
);
}
}
...
...
src/service/Common.ts
View file @
f21881b9
...
@@ -7,8 +7,11 @@ import {
...
@@ -7,8 +7,11 @@ import {
updateDrafts
,
updateDrafts
,
}
from
'@/utils/api/userApi'
;
}
from
'@/utils/api/userApi'
;
import
{
typeTones
,
typeSoundColor
}
from
'@/service/CreateLive'
;
import
{
typeTones
,
typeSoundColor
}
from
'@/service/CreateLive'
;
import
{
show_message
}
from
'@/utils/tool'
;
import
{
show_message
,
alyOssUpload
}
from
'@/utils/tool'
;
import
{
LIVE_AUDIT_STATUS
}
from
'./Live'
;
import
{
LIVE_AUDIT_STATUS
}
from
'./Live'
;
import
{
audioMerge
,
splitAudio
}
from
'@/utils/audio'
;
import
{
v4
}
from
'uuid'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
// 阿里云上传配置
// 阿里云上传配置
export
const
getUploadConfig
=
async
()
=>
{
export
const
getUploadConfig
=
async
()
=>
{
...
@@ -112,6 +115,10 @@ export const onUpdateLiveTask = async (id: any, data: any) => {
...
@@ -112,6 +115,10 @@ export const onUpdateLiveTask = async (id: any, data: any) => {
}
}
return
false
;
return
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'common onUpdateLiveTask error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
return
false
;
return
false
;
}
}
...
@@ -127,7 +134,87 @@ export const onUpdateDrafts = async (id: any, data: any) => {
...
@@ -127,7 +134,87 @@ export const onUpdateDrafts = async (id: any, data: any) => {
}
}
return
false
;
return
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'common onUpdateDrafts error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
return
false
;
return
false
;
}
}
};
};
// 音频合并切割
export
const
audioStart
=
async
(
list
:
any
[],
dimensional
:
boolean
=
true
)
=>
{
let
file
=
await
audioMerge
(
list
);
if
(
file
)
{
// 开始切割
let
split_list
=
await
splitAudio
(
file
,
300
);
// 合并后的文件上传
if
(
split_list
&&
split_list
.
length
)
{
let
result
=
await
uploadToAly
(
split_list
);
console
.
log
(
'上传完毕'
);
// 是否一维数组
if
(
dimensional
)
{
console
.
log
(
result
);
return
result
;
}
else
{
console
.
log
([
result
]);
return
[
result
];
}
}
}
else
{
console
.
log
(
'没有文件'
);
}
};
// 循环上传阿里云
export
const
uploadToAly
=
async
(
fileList
:
File
[])
=>
{
// 获取文件名
const
getFileName
=
(
file
:
any
)
=>
{
return
file
.
name
?
file
.
name
:
v4
();
};
const
uploadSuccess
=
(
name
:
string
,
url
:
string
)
=>
{
alyList
.
push
([
{
content
:
url
,
},
]);
};
// 每次上传前清空数组
let
alyList
=
[];
console
.
log
(
'任务数'
);
console
.
log
(
fileList
.
length
);
// 获取阿里云配置
let
config
=
await
getUploadConfig
();
for
(
let
i
=
0
;
i
<
fileList
.
length
;
i
++
)
{
let
file
=
fileList
[
i
];
let
retryNum
=
0
;
while
(
true
)
{
if
(
retryNum
>=
5
)
{
console
.
log
(
'音频块已经重试5次,跳过'
);
break
;
}
if
(
retryNum
)
{
config
=
await
getUploadConfig
();
}
try
{
// 上传阿里云
await
alyOssUpload
(
config
,
file
,
uploadSuccess
,
()
=>
false
,
getFileName
(
file
));
}
catch
(
e
)
{
writeLog
({
name
:
'common uploadToAly.alyOssUpload error'
,
value
:
e
,
});
if
(
e
&&
e
.
status
==
'error'
)
{
// 重新上传
console
.
log
(
'重新上传'
);
retryNum
+=
1
;
continue
;
}
}
break
;
}
}
// 上传完毕
return
alyList
;
};
src/service/CreateLive.ts
View file @
f21881b9
import
{
mergedArray
}
from
'@/utils/tool'
;
import
{
mergedArray
,
isDev
,
show_message
,
dimensionalConvert
,
DataType
}
from
'@/utils/tool'
;
import
{
liveContentRegenerateCallback
,
liveTts
,
getLiveTtsCallback
,
liveTaskRegenerate
}
from
'@/utils/api/userApi'
;
import
{
audioStart
}
from
'@/service/Common'
;
import
store
from
'@/store'
;
import
{
v4
}
from
'uuid'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
/**
* 创建直播的版本
* v1-同步执行,直到洗稿和提交完毕
* v2-异步执行
*/
export
const
createLiveVersion
=
'v2'
;
// 创建直播时提交的变量名
// 创建直播时提交的变量名
export
const
createLiveKeys
=
{
export
const
createLiveKeys
=
{
id_type
:
'id_type'
,
// 数字人库类型(数字人库和我的数字人)
id_type
:
'id_type'
,
// 数字人库类型(数字人库和我的数字人)
...
@@ -50,3 +63,306 @@ export const mergeSameAudio = (content: any[]) => {
...
@@ -50,3 +63,306 @@ export const mergeSameAudio = (content: any[]) => {
};
};
});
});
};
};
// 获取洗稿回调
export
const
onRewriteCallback
=
async
(
id
:
string
)
=>
{
return
new
Promise
<
any
[]
>
((
resolve
)
=>
{
let
interval
=
null
;
console
.
log
(
'开启轮询,洗稿回调'
);
// 关闭定时器
const
closeConfuseInterval
=
()
=>
{
window
.
clearInterval
(
interval
);
clearInterval
(
interval
);
interval
=
null
;
};
// 回调方法
const
currentStartConfuseBack
=
async
(
id
:
any
)
=>
{
try
{
let
res
:
any
=
await
liveContentRegenerateCallback
({
task_id
:
id
,
});
if
(
isDev
())
{
//
res
.
data
=
[
{
content
:
`
大家好!欢迎来到今天的直播!我是你们的主持人,今天我将为大家带来一场精彩的直播节目。在这里,我们将分享一些有趣的内容,并回答你们的问题。
首先,让我们来聊一聊今天的主题。今天我们将重点聚焦在XX领域(根据直播主题填写),这是一个非常热门、有趣且前沿的领域。我们将了解最新的发展动态、分享一些实用的技巧,并回答你们提出的问题。
对于新加入直播的朋友,特别欢迎你们!如果你们有任何问题或者想要了解更多关于XX的信息,请随时在评论区留言,我将尽力回答你们的问题。
在这里,我们鼓励大家积极互动。请大家在评论区留下你们的想法、观点和问题。我会选择一些与主题相关的问题进行回答,在回答问题时我会尽量深入浅出,以确保每个人都能够理解。
也请大家相互尊重,遵守礼貌。如果有令人不舒服的言论或者不适当的内容,请及时举报,我们会及时处理。
接下来,让我们一起进入今天的正题吧!不管你是刚开始接触XX,还是已经有一定了解,请相信你们在这里能够获得更多知识、更多的收获。
再次感谢大家的到来和支持,让我们一起度过这个精彩的时刻!祝愿大家在本次直播中有所收获,也希望大家能够在评论区互相交流,共同进步。
谢谢大家!现在,让我们开始今天的直播吧!
`
,
},
];
}
if
(
res
.
code
==
0
&&
res
.
data
.
length
)
{
console
.
log
(
'洗稿回调成功'
);
closeConfuseInterval
();
// 返回值
resolve
(
res
.
data
);
}
else
{
console
.
log
(
'洗稿还没有回调'
,
id
);
console
.
log
(
res
.
data
);
}
}
catch
(
e
)
{
writeLog
({
name
:
'service onRewriteCallback.currentStartConfuseBack error'
,
value
:
e
,
});
console
.
log
(
e
);
}
};
// 打开定时器
interval
=
window
.
setInterval
(()
=>
{
currentStartConfuseBack
(
id
);
},
3000
);
});
};
// 提交音频任务
export
const
submitAudioTask
=
async
(
list
:
any
[],
item
:
any
,
uuid
:
string
)
=>
{
try
{
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
let
params
=
{
// 音色
phonetic_timbres_id
:
item
[
createLiveKeys
.
textSoundColor
],
// 音调
tone_id
:
item
[
createLiveKeys
.
textTones
],
content
:
list
[
i
].
content
,
uuid
:
uuid
,
};
// 生成音频
await
liveTts
(
params
);
}
console
.
log
(
'等待音频生成完成'
);
return
true
;
}
catch
(
e
)
{
// 日志
writeLog
({
name
:
'service 提交音频任务失败'
,
value
:
e
,
});
console
.
log
(
e
);
return
false
;
}
// 开始轮询
// openInterval(true, '', true, currentConfuseId.value, false, list.length);
};
// 过滤必要的字段
export
const
filterFiled
=
(
item
:
any
,
type
:
string
=
''
)
=>
{
// 过滤必须字段
let
params
:
any
=
{};
params
.
name
=
store
.
getters
[
'live/getName'
];
// 数字人id
params
.
digital_man_id
=
item
[
createLiveKeys
.
id
];
// 是否洗稿
params
.
is_disorganize
=
item
[
createLiveKeys
.
isDisorganize
];
// 脚本类型
params
.
type
=
item
[
createLiveKeys
.
scriptType
];
// 脚本内容
if
(
item
[
createLiveKeys
.
scriptType
]
==
scriptTypeText
)
{
// 文本
params
.
type_content
=
item
[
createLiveKeys
.
textScriptValue
];
// 转换格式
// 先二维转一维
params
.
type_content
=
dimensionalConvert
(
params
.
type_content
);
let
list
=
[];
params
.
type_content
.
forEach
((
item
:
any
)
=>
{
list
.
push
([
item
]);
});
params
.
type_content
=
list
;
console
.
log
(
params
.
type_content
,
'文本 type_content'
);
// 音色id
params
.
phonetic_timbres_id
=
item
[
createLiveKeys
.
textSoundColor
];
// 文本内容--先转一维数组
let
newList
=
dimensionalConvert
(
item
[
createLiveKeys
.
textScriptList
]);
params
.
content
=
newList
.
map
((
row
:
any
)
=>
{
return
{
title
:
row
.
title
,
content
:
row
.
content
,
};
});
}
else
{
// 切割后的音频格式
const
audioConversion
=
(
list
:
any
[])
=>
{
return
list
.
map
((
child
:
any
)
=>
{
return
child
.
audio_url
;
})
.
join
(
'|'
);
};
// 音频
params
.
type_content
=
item
[
createLiveKeys
.
audioScriptList
].
map
((
audioScript
:
any
)
=>
{
let
list
=
[];
audioScript
.
data
.
forEach
((
it
:
any
)
=>
{
let
params
:
any
=
{
content
:
''
,
old_content
:
''
,
name
:
''
,
uuid
:
v4
(),
duration
:
0
,
};
if
(
it
.
duration
)
{
params
.
duration
=
parseInt
(
it
.
duration
);
}
// 草稿类型的
if
(
type
==
'edit_drafts'
)
{
if
(
it
.
children
&&
it
.
children
.
length
>
1
)
{
// 有切割的
params
.
content
=
audioConversion
(
it
.
children
);
}
if
(
it
.
old_content
)
{
params
.
old_content
=
it
.
old_content
;
}
else
if
(
it
.
url
)
{
params
.
old_content
=
it
.
url
;
}
if
(
it
.
content
)
{
params
.
content
=
it
.
content
;
}
else
if
(
it
.
url
)
{
params
.
content
=
it
.
url
;
}
}
else
{
// 获取编辑状态下的content
if
(
it
.
children
&&
it
.
children
.
length
>
1
)
{
// 修改content
params
.
content
=
audioConversion
(
it
.
children
);
params
.
old_content
=
it
.
audio_url
;
}
else
{
if
(
typeof
it
===
'string'
)
{
params
.
content
=
it
;
params
.
old_content
=
it
;
}
else
if
(
it
.
url
)
{
params
.
content
=
it
.
url
;
params
.
old_content
=
it
.
url
;
}
else
{
params
.
content
=
it
.
audio_url
;
params
.
old_content
=
it
.
audio_url
;
}
}
}
// 切割后的
if
(
typeof
it
!==
'string'
&&
it
.
new_content
)
{
params
.
content
=
it
.
new_content
;
}
// 获取文件名
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
);
});
return
list
;
});
console
.
log
(
params
.
type_content
,
'音频 type_content'
);
// 音色id
params
.
phonetic_timbres_id
=
item
[
createLiveKeys
.
phoneticsSoundColor
];
}
// 音调id
params
.
tone_id
=
item
[
createLiveKeys
.
textTones
];
// 互动库
params
.
interaction_ids
=
item
[
createLiveKeys
.
interactiveLibrary
];
return
params
;
};
export
const
regenerate
=
async
(
list
:
any
[],
item
:
any
,
live_id
:
any
)
=>
{
try
{
let
params
=
filterFiled
(
item
);
params
.
type_content
=
list
;
let
res
:
any
=
await
liveTaskRegenerate
(
live_id
,
params
);
if
(
res
.
code
==
0
)
{
console
.
log
(
JSON
.
stringify
(
params
));
writeLog
(
'重新生成直播,已经提交-'
+
live_id
);
console
.
log
(
'重新生成直播,已经提交-'
,
live_id
);
}
}
catch
(
e
)
{
writeLog
({
name
:
'service createLive regenerate error'
,
value
:
e
,
});
console
.
log
(
e
);
}
};
// 洗稿获取音频回调
export
const
getAudioCallback
=
(
audio_task_id
:
string
,
len
:
number
,
liveInfo
:
any
,
live_id
:
any
)
=>
{
let
interval
=
null
;
// 关闭定时器
const
closeInterval
=
()
=>
{
window
.
clearInterval
(
interval
);
clearInterval
(
interval
);
interval
=
null
;
};
const
getTaskStatus
=
async
()
=>
{
try
{
let
res
:
any
=
await
getLiveTtsCallback
({
task_id
:
audio_task_id
,
});
if
(
res
.
code
==
0
)
{
if
(
isDev
())
{
let
params
=
{
data
:
{
audio_address
:
'http://nls-cloud-cn-shanghai.oss-cn-shanghai.aliyuncs.com/jupiter-flow/tmp/e56d8750eb3a44f9930f73703489acb1.wav?Expires=1692087730&OSSAccessKeyId=LTAIUpwNp2H7pBG5&Signature=FtKSld5Dn55po9GyTm%2BefRKmPqw%3D'
,
task_id
:
0
,
},
};
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
res
.
data
.
push
(
params
);
}
}
if
(
res
.
data
.
length
)
{
console
.
log
(
'音频任务回调成功'
);
console
.
log
(
res
.
data
);
if
(
res
.
data
.
length
>=
len
)
{
closeInterval
();
let
audio_list
=
[];
// 洗稿任务
res
.
data
.
forEach
((
item
:
any
)
=>
{
let
data
=
item
.
data
;
if
(
data
&&
data
.
audio_address
)
{
audio_list
.
push
(
data
.
audio_address
);
}
else
{
console
.
log
(
'洗稿缺少参数'
);
show_message
(
'洗稿缺少参数'
);
}
});
let
resultList
=
await
audioStart
(
audio_list
,
true
);
// 提交
await
regenerate
(
resultList
,
liveInfo
,
live_id
);
}
}
}
}
catch
(
e
)
{
writeLog
({
name
:
'service createLive getTaskStatus error'
,
value
:
e
,
});
console
.
log
(
e
);
}
};
interval
=
window
.
setInterval
(()
=>
{
getTaskStatus
();
},
3000
);
};
src/store/index.ts
View file @
f21881b9
...
@@ -5,6 +5,7 @@ import theme from './modules/theme';
...
@@ -5,6 +5,7 @@ import theme from './modules/theme';
import
language
from
'./modules/language'
;
import
language
from
'./modules/language'
;
import
live
from
'./modules/live'
;
import
live
from
'./modules/live'
;
import
navbar
from
'./modules/navbar'
;
import
navbar
from
'./modules/navbar'
;
import
asyncCreateLive
from
'./modules/asyncCreateLive'
;
export
const
store
=
createStore
({
export
const
store
=
createStore
({
modules
:
{
modules
:
{
...
@@ -14,6 +15,7 @@ export const store = createStore({
...
@@ -14,6 +15,7 @@ export const store = createStore({
language
,
language
,
live
,
live
,
navbar
,
navbar
,
asyncCreateLive
,
},
},
});
});
...
...
src/store/modules/asyncCreateLive.ts
0 → 100644
View file @
f21881b9
import
{
onRewriteCallback
,
submitAudioTask
,
getAudioCallback
}
from
'@/service/CreateLive'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
const
state
=
{
language
:
''
,
};
type
StateType
=
typeof
state
;
const
mutations
=
{
// setLang(state: StateType, info: string) {
// state.language = info;
// // 设置html 属性
// document.documentElement.setAttribute('lang', info);
// },
};
const
getters
=
{
// getLang: (state: StateType) => {
// return state.language;
// },
};
const
actions
=
{
// 洗稿
async
confuse
({
commit
},
params
)
{
const
{
user_id
,
live_task_id
,
task_id
,
audio_task_id
,
createLiveInfo
}
=
params
;
try
{
// 获取洗稿回调
let
confuseList
=
await
onRewriteCallback
(
task_id
);
// 提交音频任务
let
status
=
await
submitAudioTask
(
confuseList
,
createLiveInfo
,
audio_task_id
);
if
(
status
)
{
// 打开音频回调轮询
getAudioCallback
(
audio_task_id
,
confuseList
.
length
,
createLiveInfo
,
live_task_id
);
}
}
catch
(
e
)
{
writeLog
({
name
:
'dispatch confuse error'
,
value
:
e
,
});
console
.
log
(
e
);
}
},
};
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
,
getters
,
};
src/utils/audio.ts
View file @
f21881b9
import
audiobufferToWav
from
'audiobuffer-to-wav'
;
import
audiobufferToWav
from
'audiobuffer-to-wav'
;
import
request
from
'@/utils/upLoadRequest'
;
import
request
from
'@/utils/upLoadRequest'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
export
const
createAudioContext
=
()
=>
{
export
const
createAudioContext
=
()
=>
{
return
new
(
window
.
AudioContext
||
window
.
webkitAudioContext
)();
return
new
(
window
.
AudioContext
||
window
.
webkitAudioContext
)();
...
@@ -82,14 +83,16 @@ export async function audioMerge(filePaths) {
...
@@ -82,14 +83,16 @@ export async function audioMerge(filePaths) {
offset
+=
Math
.
round
(
buffer
.
duration
*
sampleRate
);
offset
+=
Math
.
round
(
buffer
.
duration
*
sampleRate
);
});
});
console
.
log
(
buffers
);
console
.
log
(
buffers
);
console
.
log
(
'zxl'
);
// 导出合并后的音频数据为 WAV 文件
// 导出合并后的音频数据为 WAV 文件
const
mergedData
=
exportBufferAsWav
(
mergedBuffer
);
const
mergedData
=
exportBufferAsWav
(
mergedBuffer
);
console
.
log
(
'通过了'
);
const
blob
=
new
Blob
([
mergedData
],
{
type
:
'audio/wav'
});
const
blob
=
new
Blob
([
mergedData
],
{
type
:
'audio/wav'
});
console
.
log
(
'合并完成'
,
blob
);
console
.
log
(
'合并完成'
,
blob
);
return
blob
;
return
blob
;
}
catch
(
error
)
{
}
catch
(
error
)
{
writeLog
({
name
:
'音频合并失败'
,
value
:
error
,
});
console
.
error
(
'音频文件合并失败:'
,
error
);
console
.
error
(
'音频文件合并失败:'
,
error
);
}
}
}
}
...
...
src/utils/otherRequest.ts
View file @
f21881b9
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
{
writeLog
}
from
'./pyqt'
;
const
instance
:
any
=
axios
.
create
({
const
instance
:
any
=
axios
.
create
({
timeout
:
60
*
60
*
1000
,
timeout
:
60
*
60
*
1000
,
...
@@ -19,7 +20,9 @@ instance.interceptors.response.use(
...
@@ -19,7 +20,9 @@ instance.interceptors.response.use(
if
(
data
.
code
===
0
)
{
if
(
data
.
code
===
0
)
{
return
data
;
return
data
;
}
else
{
}
else
{
MessagePlugin
.
error
(
data
.
msg
||
'请求错误'
);
let
message
=
data
.
msg
||
'请求错误'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
return
Promise
.
reject
(
data
.
msg
);
return
Promise
.
reject
(
data
.
msg
);
}
}
},
},
...
@@ -28,9 +31,13 @@ instance.interceptors.response.use(
...
@@ -28,9 +31,13 @@ instance.interceptors.response.use(
if
(
'response'
in
err
)
{
if
(
'response'
in
err
)
{
const
{
message
:
msg
}
=
err
.
response
.
data
;
const
{
message
:
msg
}
=
err
.
response
.
data
;
if
(
err
.
response
.
data
.
indexOf
(
'<Code>UserDisable</Code>'
)
!==
-
1
)
{
if
(
err
.
response
.
data
.
indexOf
(
'<Code>UserDisable</Code>'
)
!==
-
1
)
{
MessagePlugin
.
error
(
'阿里云可能欠费'
);
let
message
=
'阿里云可能欠费'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
}
else
{
}
else
{
MessagePlugin
.
error
(
msg
||
'请求错误'
);
let
message
=
msg
||
'请求错误'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
}
}
return
err
.
response
;
return
err
.
response
;
}
}
...
...
src/utils/pyqt.ts
View file @
f21881b9
...
@@ -40,6 +40,17 @@ export const callPyjsInWindow = (name: string, value: any = '', callback: boolea
...
@@ -40,6 +40,17 @@ export const callPyjsInWindow = (name: string, value: any = '', callback: boolea
}
}
return
window
.
pyjs
[
name
](
JSON
.
stringify
(
value
));
return
window
.
pyjs
[
name
](
JSON
.
stringify
(
value
));
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'call python error'
,
value
:
e
,
});
console
.
error
(
e
);
console
.
error
(
e
);
}
}
};
};
// 写入日志
export
const
writeLog
=
(
value
:
any
)
=>
{
if
(
window
.
pyjs
&&
window
.
pyjs
[
'writeLog'
])
{
window
.
pyjs
[
'writeLog'
](
JSON
.
stringify
(
value
));
}
};
src/utils/request.ts
View file @
f21881b9
...
@@ -2,7 +2,7 @@ import axios from 'axios';
...
@@ -2,7 +2,7 @@ import axios from 'axios';
import
{
store
}
from
'@/store/index'
;
import
{
store
}
from
'@/store/index'
;
import
router
from
'@/router'
;
import
router
from
'@/router'
;
import
{
show_message
,
isDev
}
from
'./tool'
;
import
{
show_message
,
isDev
}
from
'./tool'
;
import
{
callPyjsInWindow
}
from
'./pyqt'
;
import
{
callPyjsInWindow
,
writeLog
}
from
'./pyqt'
;
const
error_messaage
=
'请求错误'
;
const
error_messaage
=
'请求错误'
;
...
@@ -55,6 +55,7 @@ instance.interceptors.response.use(
...
@@ -55,6 +55,7 @@ instance.interceptors.response.use(
if
(
'response'
in
err
&&
err
[
'response'
])
{
if
(
'response'
in
err
&&
err
[
'response'
])
{
const
{
status
,
data
}
=
err
.
response
;
const
{
status
,
data
}
=
err
.
response
;
if
(
status
==
401
)
{
if
(
status
==
401
)
{
writeLog
(
'登录信息已失效'
);
router
.
push
({
router
.
push
({
path
:
'/login'
,
path
:
'/login'
,
});
});
...
@@ -63,12 +64,15 @@ instance.interceptors.response.use(
...
@@ -63,12 +64,15 @@ instance.interceptors.response.use(
store
.
commit
(
'user/removeUserInfo'
);
store
.
commit
(
'user/removeUserInfo'
);
return
;
return
;
}
}
show_message
(
data
.
message
||
error_messaage
,
'error'
);
let
message
=
data
.
message
||
error_messaage
;
show_message
(
message
,
'error'
);
writeLog
(
message
);
return
err
.
response
;
return
err
.
response
;
}
else
{
}
else
{
// 格式不一致的
// 格式不一致的
let
res
=
err
.
toJSON
();
let
res
=
err
.
toJSON
();
show_message
(
res
.
message
,
'error'
);
show_message
(
res
.
message
,
'error'
);
writeLog
(
res
.
message
);
return
;
return
;
}
}
},
},
...
...
src/utils/tool.ts
View file @
f21881b9
import
{
MessagePlugin
,
RequestMethodResponse
}
from
'tdesign-vue-next'
;
import
{
MessagePlugin
,
RequestMethodResponse
}
from
'tdesign-vue-next'
;
import
request
from
'@/utils/upLoadRequest'
;
import
request
from
'@/utils/upLoadRequest'
;
import
{
writeLog
}
from
'./pyqt'
;
// import JSZip from 'jszip';
// import JSZip from 'jszip';
// import { saveAs } from 'file-saver';
// import { saveAs } from 'file-saver';
...
@@ -249,6 +250,10 @@ export const alyOssUpload = (
...
@@ -249,6 +250,10 @@ export const alyOssUpload = (
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
);
writeLog
({
name
:
'tool aly upload error'
,
value
:
e
,
});
reject
({
reject
({
status
:
'error'
,
status
:
'error'
,
response
:
''
,
response
:
''
,
...
...
src/utils/upLoadRequest.ts
View file @
f21881b9
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
writeLog
}
from
'./pyqt'
;
const
instance
:
any
=
axios
.
create
({
const
instance
:
any
=
axios
.
create
({
timeout
:
60
*
60
*
1000
,
timeout
:
60
*
60
*
1000
,
...
@@ -18,11 +19,25 @@ instance.interceptors.response.use(
...
@@ -18,11 +19,25 @@ instance.interceptors.response.use(
if
(
data
.
code
===
0
)
{
if
(
data
.
code
===
0
)
{
return
data
;
return
data
;
}
}
// 状态不对的
writeLog
({
name
:
'upLoad request status error'
,
value
:
response
,
});
},
},
(
err
)
=>
{
(
err
)
=>
{
console
.
log
(
err
);
if
(
'response'
in
err
)
{
if
(
'response'
in
err
)
{
writeLog
({
name
:
'upLoad request status error'
,
value
:
err
.
response
,
});
return
err
.
response
;
return
err
.
response
;
}
else
{
writeLog
({
name
:
'upLoad request status error'
,
value
:
err
,
});
}
}
},
},
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment