Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
accessibility_movie_2
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
赵心治
accessibility_movie_2
Commits
3ed61a1f
Commit
3ed61a1f
authored
Nov 01, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基本改完 不同旁白不同语速的部分
parent
a762942b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
151 additions
and
35 deletions
+151
-35
conf.ini
conf.ini
+3
-3
constant.py
constant.py
+6
-2
main_window.py
main_window.py
+0
-0
main_window.ui
main_window.ui
+6
-0
management.py
management.py
+9
-8
operation_dialog.py
operation_dialog.py
+33
-9
operation_dialog.ui
operation_dialog.ui
+35
-6
operation_dialog_ui.py
operation_dialog_ui.py
+13
-4
utils.py
utils.py
+46
-3
No files found.
conf.ini
View file @
3ed61a1f
云扬,男,年轻人
1.00(4字/秒)
\ No newline at end of file
晓颜,女,年轻人
1.25(5字/秒)
\ No newline at end of file
constant.py
View file @
3ed61a1f
class
Content
:
StartTimeColumn
=
0
ActivateColumn
=
2
AsideColumnNumber
=
2
ActivateColumns
=
[
2
,
3
]
# ColumnCount = 3
ObjectName
=
"all_tableWidget"
TimeFormatColumns
=
[
0
]
class
Aside
:
StartTimeColumn
=
0
AsideColumnNumber
=
3
ActivateColumns
=
[
3
,
4
]
ObjectName
=
"pb_tableWidget"
TimeFormatColumns
=
[
0
,
1
]
class
Subtitle
:
ObjectName
=
"zm_tableWidget"
TimeFormatColumns
=
[
0
,
1
]
import
os
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
class
Pathes
:
...
...
main_window.py
View file @
3ed61a1f
This diff is collapsed.
Click to expand it.
main_window.ui
View file @
3ed61a1f
...
...
@@ -528,6 +528,7 @@ QPushButton:pressed {
<addaction
name=
"separator"
/>
<addaction
name=
"action_insert_aside_from_now"
/>
<addaction
name=
"action_operate"
/>
<addaction
name=
"action_insert_subtitle_from_now"
/>
</widget>
<widget
class=
"QMenu"
name=
"menu_3"
>
<property
name=
"title"
>
...
...
@@ -613,6 +614,11 @@ QPushButton:pressed {
<string>
当前位置插入旁白
</string>
</property>
</action>
<action
name=
"action_insert_subtitle_from_now"
>
<property
name=
"text"
>
<string>
当前位置插入字幕
</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
...
...
management.py
View file @
3ed61a1f
...
...
@@ -80,12 +80,13 @@ class OperateRecord:
# 每一行的具体信息,"起始时间", "终止时间", "字幕", '建议', '解说脚本'
class
Element
:
def
__init__
(
self
,
st_time_sec
:
str
,
ed_time_sec
:
str
,
subtitle
,
suggest
,
aside
):
def
__init__
(
self
,
st_time_sec
:
str
,
ed_time_sec
:
str
,
subtitle
,
suggest
,
aside
,
speed
=
"1.00(4字/秒)"
):
self
.
st_time_sec
=
st_time_sec
self
.
ed_time_sec
=
ed_time_sec
self
.
subtitle
=
subtitle
self
.
suggest
=
suggest
self
.
aside
=
aside
self
.
speed
=
speed
# 判断当前元素是否是字幕
...
...
@@ -97,17 +98,17 @@ class Element:
return
not
self
.
is_subtitle
()
def
to_list
(
self
):
return
[
self
.
st_time_sec
,
self
.
ed_time_sec
,
self
.
subtitle
,
self
.
suggest
,
self
.
aside
]
return
[
self
.
st_time_sec
,
self
.
ed_time_sec
,
self
.
subtitle
,
self
.
suggest
,
self
.
aside
,
self
.
speed
]
def
to_short_list
(
self
):
return
[
self
.
st_time_sec
,
self
.
subtitle
,
self
.
aside
]
return
[
self
.
st_time_sec
,
self
.
subtitle
,
self
.
aside
,
self
.
speed
]
def
to_aside_list
(
self
):
return
[
self
.
st_time_sec
,
self
.
ed_time_sec
,
self
.
suggest
,
self
.
aside
]
return
[
self
.
st_time_sec
,
self
.
ed_time_sec
,
self
.
suggest
,
self
.
aside
,
self
.
speed
]
def
to_subtitle_list
(
self
):
return
[
self
.
st_time_sec
,
self
.
ed_time_sec
,
self
.
subtitle
]
def
print_self
(
self
):
print
(
"st_time_sec:"
,
self
.
st_time_sec
,
"ed_time_sec:"
,
self
.
ed_time_sec
,
"subtitle:"
,
self
.
subtitle
,
"suggest:"
,
self
.
suggest
,
"aside
"
,
self
.
aside
)
"subtitle:"
,
self
.
subtitle
,
"suggest:"
,
self
.
suggest
,
"aside
:"
,
self
.
aside
,
"speed:"
,
self
.
speed
)
def
equalTo
(
self
,
other
)
->
bool
:
return
abs
(
float
(
self
.
st_time_sec
)
-
float
(
other
.
st_time_sec
))
<
0.1
...
...
@@ -126,11 +127,11 @@ class ProjectContext:
self
.
speaker_info
=
rl
[
0
]
.
strip
()
self
.
speaker_speed
=
rl
[
1
]
.
strip
()
# 一些常量
self
.
header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
]
self
.
aside_header
=
[
"起始时间"
,
"终止时间"
,
'建议'
,
'解说脚本'
]
self
.
header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
,
"语速"
]
self
.
aside_header
=
[
"起始时间"
,
"终止时间"
,
'建议'
,
'解说脚本'
,
"语速"
]
self
.
subtitle_header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"旁白"
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"旁白"
,
"语速"
]
self
.
excel_sheet_name
=
"旁白插入位置建议"
self
.
history_records
=
[]
self
.
records_pos
=
0
...
...
operation_dialog.py
View file @
3ed61a1f
...
...
@@ -4,8 +4,8 @@ from PyQt5.QtCore import *;
from
PyQt5.QtGui
import
*
;
from
PyQt5.QtWidgets
import
*
;
import
utils
from
operation_dialog_ui
import
Ui_Dialog
from
utils
import
validate_and_get_filepath
,
replace_path_suffix
#todo 注意,删除行,添加行,暂不支持【撤销与重做】功能!!!
class
Operation_Dialog
(
QDialog
,
Ui_Dialog
):
...
...
@@ -23,7 +23,7 @@ class Operation_Dialog(QDialog, Ui_Dialog):
self
.
pushButton
.
clicked
.
connect
(
self
.
check_validate_slot
)
self
.
pushButton_2
.
clicked
.
connect
(
self
.
remake_slot
)
#如果是【修改一行】,选择行的时候要瞬间更新成目前行的内容
self
.
pushButton_3
.
clicked
.
connect
(
self
.
row_num_change
_slot
)
self
.
pushButton_3
.
clicked
.
connect
(
self
.
fill_row_info
_slot
)
self
.
buttonBox
.
setEnabled
(
False
)
self
.
buttonBox
.
button
(
QDialogButtonBox
.
StandardButton
.
Ok
)
.
clicked
.
connect
(
self
.
start_operation_slot
)
...
...
@@ -31,7 +31,8 @@ class Operation_Dialog(QDialog, Ui_Dialog):
self
.
comboBox
.
currentIndexChanged
.
connect
(
self
.
zmpb_change_slot
)
# 增加一行/删除一行 选择框
self
.
comboBox_2
.
currentIndexChanged
.
connect
(
self
.
adddel_change_slot
)
self
.
speed_list
=
[
"1.00(4字/秒)"
,
"1.10(4.5字/秒)"
,
"1.25(5字/秒)"
,
"1.50(6字/秒)"
,
"1.75(7字/秒)"
,
"2.00(8字/秒)"
,
"2.50(10字/秒)"
]
self
.
comboBox_3
.
addItems
(
li
)
self
.
lineEdits
=
[
self
.
lineEdit
,
self
.
lineEdit_2
,
self
.
lineEdit_3
,
self
.
lineEdit_4
,
self
.
lineEdit_5
,
self
.
lineEdit_6
]
self
.
zmpb_change_slot
()
...
...
@@ -72,15 +73,30 @@ class Operation_Dialog(QDialog, Ui_Dialog):
except
Exception
as
e
:
self
.
mainWindow
.
prompt_dialog
.
show_with_msg
(
"校验失败!总行数为[
%
d],你的输入为[
%
s]!!"
%
(
rowCount
,
self
.
lineEdit
.
text
()))
return
False
# 校验时间填写是否是hh:mm:ss格式的
try
:
import
re
if
type
(
self
.
lineEdit_2
.
text
())
==
str
and
len
(
self
.
lineEdit_2
.
text
())
>
0
:
x
=
re
.
match
(
"^(([0-1]
\
d)|(2[0-4])):[0-5]
\
d:[0-5]
\
d(.
\
d{1,2})?$"
,
self
.
lineEdit_2
.
text
())
assert
x
!=
None
if
type
(
self
.
lineEdit_3
.
text
())
==
str
and
len
(
self
.
lineEdit_3
.
text
())
>
0
:
x
=
re
.
match
(
"^(([0-1]
\
d)|(2[0-4])):[0-5]
\
d:[0-5]
\
d(.
\
d{1,2})?$"
,
self
.
lineEdit_3
.
text
())
assert
x
!=
None
except
Exception
as
e
:
self
.
mainWindow
.
prompt_dialog
.
show_with_msg
(
"校验失败!起始或结束时间输入的格式有误!应该为hh:mm:ss!!"
%
(
rowCount
,
self
.
lineEdit
.
text
()))
return
False
# 这些是只有【add】才需要检测的
if
self
.
comboBox_2
.
currentText
()
==
"增加一行"
:
#校验起始时间、结束时间
start_time_f
,
end_time_f
=
0.0
,
0.0
try
:
start_time_f
=
float
(
self
.
lineEdit_2
.
text
(
))
start_time_f
=
float
(
utils
.
trans_to_seconds
(
self
.
lineEdit_2
.
text
()
))
if
self
.
comboBox
.
currentText
()
==
"字幕"
:
end_time_f
=
float
(
self
.
lineEdit_3
.
text
(
))
end_time_f
=
float
(
utils
.
trans_to_seconds
(
self
.
lineEdit_3
.
text
()
))
assert
start_time_f
<
end_time_f
except
Exception
as
e
:
self
.
mainWindow
.
prompt_dialog
.
show_with_msg
(
"校验失败!起始时间或结束时间输入有误!!"
)
...
...
@@ -123,6 +139,12 @@ class Operation_Dialog(QDialog, Ui_Dialog):
row
,
start_time
,
end_time
,
subtitle
,
suggest
,
aside
=
[
x
.
text
()
for
x
in
self
.
lineEdits
]
# 将hh:mm:ss转成秒的形式传给mainWindow
if
type
(
start_time
)
==
str
and
len
(
start_time
)
>
0
:
start_time
=
str
(
utils
.
trans_to_seconds
(
start_time
))
if
type
(
end_time
)
==
str
and
len
(
end_time
)
>
0
:
end_time
=
str
(
utils
.
trans_to_seconds
(
end_time
))
if
self
.
comboBox
.
currentText
()
==
"字幕"
:
suggest
=
""
aside
=
""
...
...
@@ -144,22 +166,24 @@ class Operation_Dialog(QDialog, Ui_Dialog):
else
:
self
.
start_del_signal
.
emit
(
row
,
start_time
,
end_time
,
subtitle
,
suggest
,
aside
)
def
row_num_change
_slot
(
self
):
def
fill_row_info
_slot
(
self
):
text
=
self
.
lineEdit
.
text
()
print
(
"
row_num_change
_slot, text:"
,
text
)
print
(
"
fill_row_info
_slot, text:"
,
text
)
if
text
is
not
None
:
try
:
rowCount
=
self
.
mainWindow
.
all_tableWidget
.
rowCount
()
row_number
=
int
(
self
.
lineEdit
.
text
())
assert
1
<=
row_number
<=
rowCount
elem
=
self
.
mainWindow
.
projectContext
.
all_elements
[
int
(
row_number
)
-
1
]
self
.
lineEdit_2
.
setText
(
elem
.
st_time_sec
)
self
.
lineEdit_3
.
setText
(
elem
.
ed_time_sec
)
self
.
lineEdit_2
.
setText
(
str
(
utils
.
transfer_second_to_time
(
elem
.
st_time_sec
))
)
self
.
lineEdit_3
.
setText
(
str
(
utils
.
transfer_second_to_time
(
elem
.
ed_time_sec
))
)
self
.
lineEdit_4
.
setText
(
elem
.
subtitle
)
self
.
lineEdit_5
.
setText
(
elem
.
suggest
[
elem
.
suggest
.
index
(
"推荐字数为"
)
+
5
:])
self
.
lineEdit_6
.
setText
(
elem
.
aside
)
# 如果是旁白的话
if
elem
.
suggest
is
not
None
and
"推荐字数为"
in
elem
.
suggest
:
self
.
lineEdit_5
.
setText
(
elem
.
suggest
[
elem
.
suggest
.
index
(
"推荐字数为"
)
+
5
:])
self
.
comboBox_3
.
setCurrentIndex
(
self
.
speed_list
.
index
(
elem
.
speed
))
except
Exception
as
e
:
print
(
"exception:"
,
e
)
pass
...
...
operation_dialog.ui
View file @
3ed61a1f
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
680
</width>
<height>
4
2
7
</height>
<width>
737
</width>
<height>
4
3
7
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -19,8 +19,8 @@
</property>
<property
name=
"geometry"
>
<rect>
<x>
4
7
0
</x>
<y>
3
5
0
</y>
<x>
4
8
0
</x>
<y>
3
8
0
</y>
<width>
101
</width>
<height>
32
</height>
</rect>
...
...
@@ -324,7 +324,7 @@
<property
name=
"geometry"
>
<rect>
<x>
350
</x>
<y>
3
5
0
</y>
<y>
3
8
0
</y>
<width>
93
</width>
<height>
28
</height>
</rect>
...
...
@@ -337,7 +337,7 @@
<property
name=
"geometry"
>
<rect>
<x>
230
</x>
<y>
3
5
0
</y>
<y>
3
8
0
</y>
<width>
93
</width>
<height>
28
</height>
</rect>
...
...
@@ -378,6 +378,35 @@
行信息
</string>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"comboBox_3"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"geometry"
>
<rect>
<x>
540
</x>
<y>
310
</y>
<width>
101
</width>
<height>
22
</height>
</rect>
</property>
<property
name=
"editable"
>
<bool>
false
</bool>
</property>
</widget>
<widget
class=
"QLabel"
name=
"label_14"
>
<property
name=
"geometry"
>
<rect>
<x>
480
</x>
<y>
310
</y>
<width>
41
</width>
<height>
20
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
语速:
</string>
</property>
</widget>
</widget>
<resources/>
<connections>
...
...
operation_dialog_ui.py
View file @
3ed61a1f
...
...
@@ -12,10 +12,10 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class
Ui_Dialog
(
object
):
def
setupUi
(
self
,
Dialog
):
Dialog
.
setObjectName
(
"Dialog"
)
Dialog
.
resize
(
680
,
42
7
)
Dialog
.
resize
(
737
,
43
7
)
self
.
buttonBox
=
QtWidgets
.
QDialogButtonBox
(
Dialog
)
self
.
buttonBox
.
setEnabled
(
False
)
self
.
buttonBox
.
setGeometry
(
QtCore
.
QRect
(
4
70
,
35
0
,
101
,
32
))
self
.
buttonBox
.
setGeometry
(
QtCore
.
QRect
(
4
80
,
38
0
,
101
,
32
))
self
.
buttonBox
.
setToolTip
(
""
)
self
.
buttonBox
.
setToolTipDuration
(
-
1
)
self
.
buttonBox
.
setOrientation
(
QtCore
.
Qt
.
Horizontal
)
...
...
@@ -94,10 +94,10 @@ class Ui_Dialog(object):
self
.
label_12
.
setGeometry
(
QtCore
.
QRect
(
250
,
270
,
251
,
20
))
self
.
label_12
.
setObjectName
(
"label_12"
)
self
.
pushButton
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton
.
setGeometry
(
QtCore
.
QRect
(
350
,
3
5
0
,
93
,
28
))
self
.
pushButton
.
setGeometry
(
QtCore
.
QRect
(
350
,
3
8
0
,
93
,
28
))
self
.
pushButton
.
setObjectName
(
"pushButton"
)
self
.
pushButton_2
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton_2
.
setGeometry
(
QtCore
.
QRect
(
230
,
3
5
0
,
93
,
28
))
self
.
pushButton_2
.
setGeometry
(
QtCore
.
QRect
(
230
,
3
8
0
,
93
,
28
))
self
.
pushButton_2
.
setObjectName
(
"pushButton_2"
)
self
.
label_13
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_13
.
setGeometry
(
QtCore
.
QRect
(
250
,
90
,
311
,
21
))
...
...
@@ -108,6 +108,14 @@ class Ui_Dialog(object):
self
.
pushButton_3
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton_3
.
setGeometry
(
QtCore
.
QRect
(
540
,
60
,
71
,
61
))
self
.
pushButton_3
.
setObjectName
(
"pushButton_3"
)
self
.
comboBox_3
=
QtWidgets
.
QComboBox
(
Dialog
)
self
.
comboBox_3
.
setEnabled
(
True
)
self
.
comboBox_3
.
setGeometry
(
QtCore
.
QRect
(
540
,
310
,
101
,
22
))
self
.
comboBox_3
.
setEditable
(
False
)
self
.
comboBox_3
.
setObjectName
(
"comboBox_3"
)
self
.
label_14
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_14
.
setGeometry
(
QtCore
.
QRect
(
480
,
310
,
41
,
20
))
self
.
label_14
.
setObjectName
(
"label_14"
)
self
.
retranslateUi
(
Dialog
)
self
.
buttonBox
.
rejected
.
connect
(
Dialog
.
reject
)
...
...
@@ -139,5 +147,6 @@ class Ui_Dialog(object):
self
.
label_13
.
setText
(
_translate
(
"Dialog"
,
"*需要填在【字幕旁白】页面中的行数"
))
self
.
pushButton_3
.
setText
(
_translate
(
"Dialog"
,
"填充
\n
"
"行信息"
))
self
.
label_14
.
setText
(
_translate
(
"Dialog"
,
"语速:"
))
utils.py
View file @
3ed61a1f
...
...
@@ -26,13 +26,17 @@ def trans_to_seconds(timePoint: str) -> float:
return
time_in_seconds
def
transfer_second_to_time
(
sec
:
str
)
->
str
:
"""
输入xxxx.xxx秒,输出xx:xx:xx.xx的格式(输出不一定有小数点)
"""
duration
=
int
(
float
(
sec
))
minutes
=
int
(
duration
/
60
)
seconds
=
int
(
duration
-
60
*
minutes
)
hour
=
int
(
duration
/
3600
)
minutes
=
int
((
duration
%
3600
)
/
60
)
seconds
=
int
(
duration
%
60
)
idx
=
sec
.
find
(
'.'
)
if
(
idx
==
-
1
):
idx
=
len
(
sec
)
time
=
"
%02
d:
%02
d
%
s"
%
(
minutes
,
seconds
,
sec
[
idx
:
])
time
=
"
%02
d:
%02
d
:
%02
d
%
s"
%
(
hour
,
minutes
,
seconds
,
sec
[
idx
:
idx
+
3
])
return
time
def
replace_path_suffix
(
path
,
new_suffix
):
...
...
@@ -80,3 +84,41 @@ def get_sheetHead(book_path: str) -> list:
if
__name__
==
'__main__'
:
x
=
transfer_second_to_time
(
"12000.923"
)
print
(
x
)
x
=
transfer_second_to_time
(
"79.925"
)
print
(
x
)
y
=
trans_to_seconds
(
"1:00:00.92"
)
print
(
y
)
z
=
transfer_second_to_time
(
"1200.923"
)
print
(
z
)
import
time
strtime
=
"1:00:00.92"
# time.strptime(strtime, "%H:%M:%S")
import
re
print
(
"------------"
*
10
)
# tests = ["00:12:34a", "01:12:34", "10:12:34.567", "12:12:34.89", "24:12:34.8", "2:34.2", "12:34.", "12:34.0", "02:34.0", "00:34.0"]
tests
=
[
"01:12:34"
,
"10:12:34.567"
,
"12:12:34.89"
,
"24:12:34.8"
,
"2:34.2"
,
"12:12:34."
,
"01:12:34.0"
,
"02:02:34.0"
,
"00:00:34.0"
]
for
s
in
tests
:
x
=
re
.
match
(
"^(([0-1]
\
d)|(2[0-4])):[0-5]
\
d:[0-5]
\
d(.
\
d{1,2})?$"
,
s
)
print
(
"当前="
,
s
)
print
(
x
)
if
x
:
print
(
x
.
group
())
print
(
x
.
group
(
1
))
print
(
"---------------------------------"
)
# print(re.match("^(([0-1]\d)|(2[0-4])):[0-5]\d$", "a12:34"))
# print(re.match("^(([0-1]\d)|(2[0-4])):[0-5]\d$", "a"))
# print(re.match("[^abc]", "plain"))
# print("------------")
# q = re.match("p|(pl)ain", "plain")
# print(q)
# print(q.group())
# print("------------")
# qq = re.match("ya(msen|nsen|nsem)", "yansen’s blog")
# print(qq)
# print(qq.group())
# print(qq.group(1))
\ No newline at end of file
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