Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
text2video-frontend
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周成波
text2video-frontend
Commits
b19b752c
Commit
b19b752c
authored
Apr 15, 2024
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加分镜模式
parent
cd50ee18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
26 deletions
+29
-26
utils.ts
src/utils/utils.ts
+23
-23
index.vue
src/views/home/index.vue
+6
-3
No files found.
src/utils/utils.ts
View file @
b19b752c
...
...
@@ -38,41 +38,41 @@ export default class utils {
static
splitDetailText
(
sentences
:
string
[])
{
// console.log(sentences)
let
result_sentences
:
string
[]
=
[];
sentences
.
forEach
(
s
=>
{
if
(
s
.
length
<=
15
){
result_sentences
.
push
(
s
);
}
else
{
let
detail_array
=
s
.
split
(
/
[
,|,
]
/
);
let
currentSentence
=
''
;
for
(
let
i
=
0
;
i
<
detail_array
.
length
;
i
++
)
{
const
str
=
detail_array
[
i
];
currentSentence
+=
str
+
','
;
if
(
i
<
detail_array
.
length
-
1
&&
(
currentSentence
+
detail_array
[
i
+
1
]).
length
<=
15
)
{
continue
;
}
result_sentences
.
push
(
currentSentence
.
endsWith
(
","
)
?
currentSentence
.
slice
(
0
,
-
1
)
:
currentSentence
);
currentSentence
=
''
;
}
// console.log('result_sentences=', result_sentences);
let
currentSentence
=
''
;
for
(
let
i
=
0
;
i
<
sentences
.
length
;
i
++
)
{
const
str
=
sentences
[
i
];
currentSentence
+=
str
+
','
;
if
(
i
<
sentences
.
length
-
1
&&
(
currentSentence
+
sentences
[
i
+
1
]).
length
<=
15
)
{
continue
;
}
});
result_sentences
.
push
(
currentSentence
.
endsWith
(
","
)
?
currentSentence
.
slice
(
0
,
-
1
)
:
currentSentence
);
currentSentence
=
''
;
}
// console.log('result_sentences=', result_sentences);
return
result_sentences
;
}
// 拆分文本
static
splitText
(
str
:
string
)
{
static
splitText
(
str
:
string
,
type
:
string
=
'default'
)
{
str
=
str
.
replaceAll
(
'“'
,
''
).
replaceAll
(
'”'
,
''
)
// 使用正则表达式拆分文本
let
sentences
=
str
.
split
(
/
[
!|?|。|!|?
]
/
);
let
sentences
:
string
[]
=
[];
if
(
type
==
'default'
){
sentences
=
str
.
split
(
/
[
!|?|。|!|?
]
/
);
}
else
{
sentences
=
str
.
split
(
/
[
!|?|。|!|?|,|,
]
/
);
}
// 过滤掉长度为 0 的句子
sentences
=
sentences
.
filter
(
s
=>
s
.
length
>
0
);
// 过滤掉只包含标点符号的句子
sentences
=
sentences
.
filter
(
s
=>
!
utils
.
containsOnlyPunctuation
(
s
));
// console.log(sentences)
// return sentences
let
detailSplit
=
utils
.
splitDetailText
(
sentences
);
return
detailSplit
;
if
(
type
==
'default'
){
return
sentences
}
else
{
let
detailSplit
=
utils
.
splitDetailText
(
sentences
);
return
detailSplit
;
}
}
// 拆分英文文本
...
...
src/views/home/index.vue
View file @
b19b752c
...
...
@@ -250,7 +250,7 @@ const onAdaptRolesKeywords = async () => {
};
const
onAdapt
=
async
()
=>
{
const
onAdapt
=
async
(
type
:
string
)
=>
{
if
(
!
form
.
chatgpt_answer
||
form
.
chatgpt_answer
.
length
==
0
)
{
ElMessage
({
message
:
"文案不能为空"
,
...
...
@@ -264,7 +264,7 @@ const onAdapt = async () => {
console
.
log
(
'分镜,生成task_id='
,
form
.
task_id
)
}
// 按标点拆分成分镜
const
sentences
=
utils
.
splitText
(
form
.
chatgpt_answer
);
const
sentences
=
utils
.
splitText
(
form
.
chatgpt_answer
,
type
);
// console.log(sentences.length)
// 分镜
form
.
adapt_result_json
=
[]
...
...
@@ -1633,7 +1633,10 @@ const onSubmitInPaint = async () => {
</el-form-item>
<!-- 分镜 -->
<el-form-item>
<el-button
type=
"primary"
@
click=
"onAdapt"
>
分镜
</el-button>
<el-button
type=
"primary"
@
click=
"onAdapt('default')"
>
分镜:标准模式
</el-button>
<el-button
type=
"primary"
@
click=
"onAdapt('more_scene')"
>
分镜:更多场景模式
</el-button
>
<el-button
type=
"primary"
@
click=
"onAdaptScene"
>
推理场景({{ tuili_llm.name }})
</el-button
>
...
...
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