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
54e9918a
Commit
54e9918a
authored
Aug 31, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd
parent
5cf7cc82
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
368 additions
and
100 deletions
+368
-100
assemble_dialog.py
assemble_dialog.py
+14
-7
assemble_dialog.ui
assemble_dialog.ui
+10
-29
assemble_dialog_ui.py
assemble_dialog_ui.py
+8
-14
constant.py
constant.py
+10
-0
main_window.py
main_window.py
+96
-14
main_window.ui
main_window.ui
+4
-4
main_window_ui.py
main_window_ui.py
+4
-4
management.py
management.py
+30
-3
setting_dialog.py
setting_dialog.py
+44
-0
setting_dialog.ui
setting_dialog.ui
+71
-0
setting_dialog_ui.py
setting_dialog_ui.py
+40
-0
start.py
start.py
+9
-0
synthesis.py
synthesis.py
+26
-23
test37second.xlsx
test37second.xlsx
+0
-0
testTableWidget.py
testTableWidget.py
+2
-2
No files found.
assemble_dialog.py
View file @
54e9918a
...
@@ -21,8 +21,9 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
...
@@ -21,8 +21,9 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
# 注意这里打包成一个list,在worker端进行解参数,避免传参过多
# 注意这里打包成一个list,在worker端进行解参数,避免传参过多
start_assemble_signal
=
pyqtSignal
(
list
)
start_assemble_signal
=
pyqtSignal
(
list
)
def
__init__
(
self
):
def
__init__
(
self
,
projectContext
):
super
(
Assemble_Dialog
,
self
)
.
__init__
()
super
(
Assemble_Dialog
,
self
)
.
__init__
()
self
.
projectContext
=
projectContext
self
.
setupUi
(
self
)
self
.
setupUi
(
self
)
self
.
setWindowTitle
(
"合成"
)
self
.
setWindowTitle
(
"合成"
)
self
.
buttonBox
.
button
(
QDialogButtonBox
.
StandardButton
.
Ok
)
.
setText
(
"开始合成"
)
self
.
buttonBox
.
button
(
QDialogButtonBox
.
StandardButton
.
Ok
)
.
setText
(
"开始合成"
)
...
@@ -31,10 +32,15 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
...
@@ -31,10 +32,15 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
self
.
pushButton_2
.
clicked
.
connect
(
self
.
openTableFile
)
self
.
pushButton_2
.
clicked
.
connect
(
self
.
openTableFile
)
# 注意,不能直接绑定到buttonBox上。
# 注意,不能直接绑定到buttonBox上。
self
.
buttonBox
.
button
(
QDialogButtonBox
.
StandardButton
.
Ok
)
.
clicked
.
connect
(
self
.
start_assemble
)
self
.
buttonBox
.
button
(
QDialogButtonBox
.
StandardButton
.
Ok
)
.
clicked
.
connect
(
self
.
start_assemble
)
# todo 把所有说话人都加上来
self
.
lineEdit_3
.
setText
(
projectContext
.
speaker_info
)
self
.
comboBox
.
addItem
(
'晓秋,女,年轻人'
)
self
.
lineEdit_4
.
setText
(
projectContext
.
speaker_speed
)
self
.
comboBox
.
currentText
()
# self.show.connect(self.init_self_slot)
self
.
comboBox_2
.
addItems
([
"1.00(4字/秒)"
,
"1.10(4.5字/秒)"
,
"1.25(5字/秒)"
,
"1.50(6字/秒)"
,
"1.75(7字/秒)"
,
"2.00(8字/秒)"
,
"2.50(10字/秒)"
])
def
init_self
(
self
):
print
(
"self.projectContext.speaker_info"
,
self
.
projectContext
.
speaker_info
)
self
.
lineEdit
.
setText
(
self
.
projectContext
.
video_path
)
self
.
lineEdit_2
.
setText
(
self
.
projectContext
.
excel_path
)
self
.
lineEdit_3
.
setText
(
self
.
projectContext
.
speaker_info
)
self
.
lineEdit_4
.
setText
(
self
.
projectContext
.
speaker_speed
)
def
openFile
(
self
):
def
openFile
(
self
):
file_info
=
QFileDialog
.
getOpenFileNames
(
self
,
'选择视频'
,
os
.
getcwd
(),
"All Files(*);;Text Files(*.txt)"
)
file_info
=
QFileDialog
.
getOpenFileNames
(
self
,
'选择视频'
,
os
.
getcwd
(),
"All Files(*);;Text Files(*.txt)"
)
...
@@ -61,10 +67,11 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
...
@@ -61,10 +67,11 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
audio_dir
=
os
.
path
.
dirname
(
self
.
lineEdit
.
text
())
audio_dir
=
os
.
path
.
dirname
(
self
.
lineEdit
.
text
())
# audio_dir = replace_path_suffix(self.lineEdit.text(), "")
# audio_dir = replace_path_suffix(self.lineEdit.text(), "")
sheet_path
=
self
.
lineEdit_2
.
text
()
sheet_path
=
self
.
lineEdit_2
.
text
()
speed_info
=
self
.
comboBox_2
.
currentText
()
speaker_info
=
self
.
lineEdit_3
.
text
()
speed_info
=
self
.
lineEdit_4
.
text
()
#todo 后续变成常量存起来,或者做成配置
#todo 后续变成常量存起来,或者做成配置
caption_path
=
replace_path_suffix
(
self
.
lineEdit
.
text
(),
".srt"
)
caption_path
=
replace_path_suffix
(
self
.
lineEdit
.
text
(),
".srt"
)
speaker_info
=
self
.
comboBox
.
currentText
()
print
(
"video_path: "
,
video_path
)
print
(
"video_path: "
,
video_path
)
print
(
"audio_dir: "
,
audio_dir
)
print
(
"audio_dir: "
,
audio_dir
)
print
(
"sheet_path: "
,
sheet_path
)
print
(
"sheet_path: "
,
sheet_path
)
...
...
assemble_dialog.ui
View file @
54e9918a
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
<widget
class=
"QLineEdit"
name=
"lineEdit"
>
<widget
class=
"QLineEdit"
name=
"lineEdit"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
1
2
0
</x>
<x>
1
3
0
</x>
<y>
40
</y>
<y>
40
</y>
<width>
211
</width>
<width>
211
</width>
<height>
21
</height>
<height>
21
</height>
...
@@ -90,7 +90,7 @@
...
@@ -90,7 +90,7 @@
<widget
class=
"QLineEdit"
name=
"lineEdit_2"
>
<widget
class=
"QLineEdit"
name=
"lineEdit_2"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
1
2
0
</x>
<x>
1
3
0
</x>
<y>
90
</y>
<y>
90
</y>
<width>
211
</width>
<width>
211
</width>
<height>
21
</height>
<height>
21
</height>
...
@@ -110,19 +110,6 @@
...
@@ -110,19 +110,6 @@
<string>
表格路径
</string>
<string>
表格路径
</string>
</property>
</property>
</widget>
</widget>
<widget
class=
"QPushButton"
name=
"pushButton_3"
>
<property
name=
"geometry"
>
<rect>
<x>
360
</x>
<y>
130
</y>
<width>
101
</width>
<height>
31
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
播放旁白语音
</string>
</property>
</widget>
<widget
class=
"QLabel"
name=
"label_3"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
...
@@ -149,31 +136,25 @@
...
@@ -149,31 +136,25 @@
<string>
旁白语速:
</string>
<string>
旁白语速:
</string>
</property>
</property>
</widget>
</widget>
<widget
class=
"Q
ComboBox"
name=
"comboBox
"
>
<widget
class=
"Q
LineEdit"
name=
"lineEdit_3
"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
130
</x>
<x>
130
</x>
<y>
1
3
0
</y>
<y>
1
4
0
</y>
<width>
18
1
</width>
<width>
21
1
</width>
<height>
3
1
</height>
<height>
2
1
</height>
</rect>
</rect>
</property>
</property>
<property
name=
"currentText"
>
<string/>
</property>
</widget>
</widget>
<widget
class=
"Q
ComboBox"
name=
"comboBox_2
"
>
<widget
class=
"Q
LineEdit"
name=
"lineEdit_4
"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
130
</x>
<x>
130
</x>
<y>
19
0
</y>
<y>
20
0
</y>
<width>
15
1
</width>
<width>
21
1
</width>
<height>
3
1
</height>
<height>
2
1
</height>
</rect>
</rect>
</property>
</property>
<property
name=
"currentText"
>
<string/>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
<resources/>
...
...
assemble_dialog_ui.py
View file @
54e9918a
...
@@ -25,7 +25,7 @@ class Ui_Dialog(object):
...
@@ -25,7 +25,7 @@ class Ui_Dialog(object):
self
.
label
.
setGeometry
(
QtCore
.
QRect
(
40
,
40
,
72
,
15
))
self
.
label
.
setGeometry
(
QtCore
.
QRect
(
40
,
40
,
72
,
15
))
self
.
label
.
setObjectName
(
"label"
)
self
.
label
.
setObjectName
(
"label"
)
self
.
lineEdit
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
lineEdit
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
lineEdit
.
setGeometry
(
QtCore
.
QRect
(
1
2
0
,
40
,
211
,
21
))
self
.
lineEdit
.
setGeometry
(
QtCore
.
QRect
(
1
3
0
,
40
,
211
,
21
))
self
.
lineEdit
.
setObjectName
(
"lineEdit"
)
self
.
lineEdit
.
setObjectName
(
"lineEdit"
)
self
.
pushButton
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton
.
setGeometry
(
QtCore
.
QRect
(
360
,
40
,
101
,
31
))
self
.
pushButton
.
setGeometry
(
QtCore
.
QRect
(
360
,
40
,
101
,
31
))
...
@@ -34,28 +34,23 @@ class Ui_Dialog(object):
...
@@ -34,28 +34,23 @@ class Ui_Dialog(object):
self
.
label_2
.
setGeometry
(
QtCore
.
QRect
(
20
,
90
,
111
,
16
))
self
.
label_2
.
setGeometry
(
QtCore
.
QRect
(
20
,
90
,
111
,
16
))
self
.
label_2
.
setObjectName
(
"label_2"
)
self
.
label_2
.
setObjectName
(
"label_2"
)
self
.
lineEdit_2
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
lineEdit_2
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
lineEdit_2
.
setGeometry
(
QtCore
.
QRect
(
1
2
0
,
90
,
211
,
21
))
self
.
lineEdit_2
.
setGeometry
(
QtCore
.
QRect
(
1
3
0
,
90
,
211
,
21
))
self
.
lineEdit_2
.
setObjectName
(
"lineEdit_2"
)
self
.
lineEdit_2
.
setObjectName
(
"lineEdit_2"
)
self
.
pushButton_2
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton_2
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton_2
.
setGeometry
(
QtCore
.
QRect
(
360
,
90
,
101
,
31
))
self
.
pushButton_2
.
setGeometry
(
QtCore
.
QRect
(
360
,
90
,
101
,
31
))
self
.
pushButton_2
.
setObjectName
(
"pushButton_2"
)
self
.
pushButton_2
.
setObjectName
(
"pushButton_2"
)
self
.
pushButton_3
=
QtWidgets
.
QPushButton
(
Dialog
)
self
.
pushButton_3
.
setGeometry
(
QtCore
.
QRect
(
360
,
130
,
101
,
31
))
self
.
pushButton_3
.
setObjectName
(
"pushButton_3"
)
self
.
label_3
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_3
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_3
.
setGeometry
(
QtCore
.
QRect
(
30
,
140
,
111
,
16
))
self
.
label_3
.
setGeometry
(
QtCore
.
QRect
(
30
,
140
,
111
,
16
))
self
.
label_3
.
setObjectName
(
"label_3"
)
self
.
label_3
.
setObjectName
(
"label_3"
)
self
.
label_4
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_4
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_4
.
setGeometry
(
QtCore
.
QRect
(
30
,
200
,
111
,
16
))
self
.
label_4
.
setGeometry
(
QtCore
.
QRect
(
30
,
200
,
111
,
16
))
self
.
label_4
.
setObjectName
(
"label_4"
)
self
.
label_4
.
setObjectName
(
"label_4"
)
self
.
comboBox
=
QtWidgets
.
QComboBox
(
Dialog
)
self
.
lineEdit_3
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
comboBox
.
setGeometry
(
QtCore
.
QRect
(
130
,
130
,
181
,
31
))
self
.
lineEdit_3
.
setGeometry
(
QtCore
.
QRect
(
130
,
140
,
211
,
21
))
self
.
comboBox
.
setCurrentText
(
""
)
self
.
lineEdit_3
.
setObjectName
(
"lineEdit_3"
)
self
.
comboBox
.
setObjectName
(
"comboBox"
)
self
.
lineEdit_4
=
QtWidgets
.
QLineEdit
(
Dialog
)
self
.
comboBox_2
=
QtWidgets
.
QComboBox
(
Dialog
)
self
.
lineEdit_4
.
setGeometry
(
QtCore
.
QRect
(
130
,
200
,
211
,
21
))
self
.
comboBox_2
.
setGeometry
(
QtCore
.
QRect
(
130
,
190
,
151
,
31
))
self
.
lineEdit_4
.
setObjectName
(
"lineEdit_4"
)
self
.
comboBox_2
.
setCurrentText
(
""
)
self
.
comboBox_2
.
setObjectName
(
"comboBox_2"
)
self
.
retranslateUi
(
Dialog
)
self
.
retranslateUi
(
Dialog
)
self
.
buttonBox
.
accepted
.
connect
(
Dialog
.
accept
)
self
.
buttonBox
.
accepted
.
connect
(
Dialog
.
accept
)
...
@@ -69,7 +64,6 @@ class Ui_Dialog(object):
...
@@ -69,7 +64,6 @@ class Ui_Dialog(object):
self
.
pushButton
.
setText
(
_translate
(
"Dialog"
,
"选择文件"
))
self
.
pushButton
.
setText
(
_translate
(
"Dialog"
,
"选择文件"
))
self
.
label_2
.
setText
(
_translate
(
"Dialog"
,
"旁白脚本表格:"
))
self
.
label_2
.
setText
(
_translate
(
"Dialog"
,
"旁白脚本表格:"
))
self
.
pushButton_2
.
setText
(
_translate
(
"Dialog"
,
"表格路径"
))
self
.
pushButton_2
.
setText
(
_translate
(
"Dialog"
,
"表格路径"
))
self
.
pushButton_3
.
setText
(
_translate
(
"Dialog"
,
"播放旁白语音"
))
self
.
label_3
.
setText
(
_translate
(
"Dialog"
,
"旁白说话人:"
))
self
.
label_3
.
setText
(
_translate
(
"Dialog"
,
"旁白说话人:"
))
self
.
label_4
.
setText
(
_translate
(
"Dialog"
,
"旁白语速:"
))
self
.
label_4
.
setText
(
_translate
(
"Dialog"
,
"旁白语速:"
))
...
...
constant.py
View file @
54e9918a
class
Content
:
class
Content
:
StartTimeColumn
=
0
ActivateColumn
=
2
ActivateColumn
=
2
# ColumnCount = 3
# ColumnCount = 3
ObjectName
=
"all_tableWidget"
class
Aside
:
class
Aside
:
StartTimeColumn
=
0
AsideColumnNumber
=
4
AsideColumnNumber
=
4
ObjectName
=
"pb_tableWidget"
import
os
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
class
Pathes
:
speaker_conf_path
=
os
.
path
.
join
(
dir_path
,
"speakers.json"
)
\ No newline at end of file
main_window.py
View file @
54e9918a
...
@@ -10,6 +10,7 @@ from management import RunThread, ProjectContext, Element
...
@@ -10,6 +10,7 @@ from management import RunThread, ProjectContext, Element
from
detect_dialog
import
Detect_Dialog
from
detect_dialog
import
Detect_Dialog
from
assemble_dialog
import
Assemble_Dialog
from
assemble_dialog
import
Assemble_Dialog
from
prompt_dialog
import
Prompt_Dialog
from
prompt_dialog
import
Prompt_Dialog
from
setting_dialog
import
Setting_Dialog
from
synthesis
import
SynthesisProcessor
from
synthesis
import
SynthesisProcessor
from
myVideoWidget
import
myVideoWidget
from
myVideoWidget
import
myVideoWidget
from
myvideoslider
import
myVideoSlider
from
myvideoslider
import
myVideoSlider
...
@@ -35,9 +36,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -35,9 +36,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
detect_dialog
.
start_detect_signal
.
connect
(
self
.
start_detect
)
self
.
detect_dialog
.
start_detect_signal
.
connect
(
self
.
start_detect
)
#合成对话框
#合成对话框
self
.
assemble_dialog
=
Assemble_Dialog
()
self
.
assemble_dialog
=
Assemble_Dialog
(
self
.
projectContext
)
self
.
assemble_dialog
.
start_assemble_signal
.
connect
(
self
.
synthesis
.
synthesis_slot
)
self
.
assemble_dialog
.
start_assemble_signal
.
connect
(
self
.
synthesis
.
synthesis_slot
)
#设置框
self
.
setting_dialog
=
Setting_Dialog
(
self
.
projectContext
)
#提示框
#提示框
self
.
prompt_dialog
=
Prompt_Dialog
()
self
.
prompt_dialog
=
Prompt_Dialog
()
...
@@ -46,6 +50,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -46,6 +50,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
detect_timer
.
timeout
.
connect
(
self
.
check_if_detect_over_slot
)
self
.
detect_timer
.
timeout
.
connect
(
self
.
check_if_detect_over_slot
)
self
.
synthesis_timer
=
QTimer
()
self
.
synthesis_timer
=
QTimer
()
self
.
synthesis_timer
.
timeout
.
connect
(
self
.
check_if_synthesis_over_slot
)
self
.
synthesis_timer
.
timeout
.
connect
(
self
.
check_if_synthesis_over_slot
)
self
.
video_timer
=
QTimer
()
self
.
video_timer
.
timeout
.
connect
(
self
.
change_videotime_label_slot
)
self
.
video_timer
.
start
(
100
)
"""
"""
状态栏相关空间
状态栏相关空间
"""
"""
...
@@ -74,6 +81,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -74,6 +81,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 菜单栏的动作
# 菜单栏的动作
self
.
actionxinjian
.
triggered
.
connect
(
self
.
show_setting_dialog
)
# 设置
self
.
actiona_3
.
triggered
.
connect
(
self
.
show_detect_dialog
)
self
.
actiona_3
.
triggered
.
connect
(
self
.
show_detect_dialog
)
self
.
actiona_4
.
triggered
.
connect
(
self
.
show_assemble_dialog
)
self
.
actiona_4
.
triggered
.
connect
(
self
.
show_assemble_dialog
)
self
.
action_save
.
triggered
.
connect
(
self
.
save_project
)
self
.
action_save
.
triggered
.
connect
(
self
.
save_project
)
...
@@ -116,11 +124,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -116,11 +124,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
pb_tableWidget
.
itemChanged
.
connect
(
self
.
write2ProjectFromAside
)
self
.
pb_tableWidget
.
itemChanged
.
connect
(
self
.
write2ProjectFromAside
)
self
.
zm_tableWidget
.
itemDoubleClicked
.
connect
(
self
.
change_video_time
)
self
.
zm_tableWidget
.
itemDoubleClicked
.
connect
(
self
.
change_video_time
)
self
.
pb_tableWidget
.
itemDoubleClicked
.
connect
(
self
.
change_video_time
)
self
.
all_tableWidget
.
itemDoubleClicked
.
connect
(
self
.
change_video_time
)
# self.all_tableWidget.itemDoubleClicked.connect(self.writeHistoryFromContent)
# self.all_tableWidget.itemDoubleClicked.connect(self.writeHistoryFromContent)
# self.all_tableWidget.itemChanged.connect(self.rewriteHistoryFromContent)
# self.all_tableWidget.itemChanged.connect(self.rewriteHistoryFromContent)
# self.all_tableWidget.itemChanged.connect(self.write2ProjectFromContent)
# self.all_tableWidget.itemChanged.connect(self.write2ProjectFromContent)
# 其他变量
#在进行redo_undo时,会触发itemchange,但是这时候不能覆写历史。但是需要写入project。(注意命名思路:在进行redo的时候,会有两步操作,写入history和写入project。我们只希望他不写入history,所以命名中要带有history)
self
.
can_write_history
=
True
# 重写关闭Mmainwindow窗口
# 重写关闭Mmainwindow窗口
def
closeEvent
(
self
,
event
):
def
closeEvent
(
self
,
event
):
...
@@ -133,7 +148,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -133,7 +148,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
show_detect_dialog
(
self
):
def
show_detect_dialog
(
self
):
self
.
detect_dialog
.
show
()
self
.
detect_dialog
.
show
()
def
show_assemble_dialog
(
self
):
def
show_assemble_dialog
(
self
):
self
.
assemble_dialog
.
init_self
()
self
.
assemble_dialog
.
show
()
self
.
assemble_dialog
.
show
()
def
show_setting_dialog
(
self
):
self
.
setting_dialog
.
show
()
def
show_warning_msg_box
(
self
,
msg
:
str
):
def
show_warning_msg_box
(
self
,
msg
:
str
):
replp
=
QtWidgets
.
QMessageBox
.
question
(
self
,
u'警告'
,
msg
,
replp
=
QtWidgets
.
QMessageBox
.
question
(
self
,
u'警告'
,
msg
,
...
@@ -149,6 +167,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -149,6 +167,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
open_project_slot
(
self
):
def
open_project_slot
(
self
):
video_path
=
self
.
openVideoFile
()
.
path
()
video_path
=
self
.
openVideoFile
()
.
path
()
print
(
"[import_slot] video_path="
+
video_path
)
print
(
"[import_slot] video_path="
+
video_path
)
if
video_path
==
""
or
video_path
==
None
:
return
print
(
os
.
path
.
dirname
(
video_path
))
print
(
os
.
path
.
dirname
(
video_path
))
print
(
os
.
path
.
basename
(
video_path
))
print
(
os
.
path
.
basename
(
video_path
))
self
.
projectContext
.
Init
(
os
.
path
.
dirname
(
video_path
),
os
.
path
.
basename
(
video_path
))
self
.
projectContext
.
Init
(
os
.
path
.
dirname
(
video_path
),
os
.
path
.
basename
(
video_path
))
...
@@ -249,6 +269,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -249,6 +269,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
for
t
in
self
.
threads
:
for
t
in
self
.
threads
:
t
.
start
()
t
.
start
()
print
(
"===子线程已经开启 in detect ==="
)
print
(
"===子线程已经开启 in detect ==="
)
self
.
statusbarLabel
.
setText
(
" 准备检测:"
)
self
.
statusbarLabel
.
setText
(
" 准备检测:"
)
...
@@ -290,8 +312,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -290,8 +312,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
for
t
in
self
.
threads
:
for
t
in
self
.
threads
:
alive
=
alive
and
t
.
is_alive
()
alive
=
alive
and
t
.
is_alive
()
if
not
alive
:
if
not
alive
:
if
type
==
"合成"
:
self
.
synthesis_timer
.
stop
()
else
:
self
.
detect_timer
.
stop
()
self
.
detect_timer
.
stop
()
print
(
"===已有线程结束了 in
detect ==="
)
print
(
"===已有线程结束了 in
%
s ==="
%
(
type
)
)
self
.
statusbarLabel
.
setText
(
"
%
s完成"
%
(
type
))
self
.
statusbarLabel
.
setText
(
"
%
s完成"
%
(
type
))
self
.
progressBar
.
setValue
(
0
)
self
.
progressBar
.
setValue
(
0
)
for
t
in
self
.
threads
:
for
t
in
self
.
threads
:
...
@@ -302,9 +327,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -302,9 +327,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
deal_synthesis_callback_slot
(
self
,
threads
,
state
):
def
deal_synthesis_callback_slot
(
self
,
threads
,
state
):
self
.
statusbarLabel
.
setText
(
" 准备合成:"
)
self
.
statusbarLabel
.
setText
(
" 准备合成:"
)
self
.
state
=
state
self
.
state
=
s
elf
.
synthesis
.
s
tate
self
.
threads
=
threads
self
.
threads
=
self
.
synthesis
.
threads
self
.
detect
_timer
.
start
(
5000
)
self
.
synthesis
_timer
.
start
(
5000
)
"""
"""
...
@@ -402,6 +427,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -402,6 +427,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
projectContext
.
load_excel_from_path
()
self
.
projectContext
.
load_excel_from_path
()
self
.
set_table_to_window
()
self
.
set_table_to_window
()
def
set_table_to_window
(
self
):
def
set_table_to_window
(
self
):
self
.
projectContext
.
initial_ing
=
True
header
=
self
.
projectContext
.
header
header
=
self
.
projectContext
.
header
subtitle_list
=
self
.
projectContext
.
subtitle_list
subtitle_list
=
self
.
projectContext
.
subtitle_list
aside_list
=
self
.
projectContext
.
aside_list
aside_list
=
self
.
projectContext
.
aside_list
...
@@ -432,18 +458,28 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -432,18 +458,28 @@ class MainWindow(QMainWindow, Ui_MainWindow):
for
i
in
range
(
len
(
all_elements
)):
for
i
in
range
(
len
(
all_elements
)):
self
.
setElememtToTable
(
self
.
all_tableWidget
,
all_elements
[
i
],
i
)
self
.
setElememtToTable
(
self
.
all_tableWidget
,
all_elements
[
i
],
i
)
self
.
projectContext
.
initial_ing
=
False
def
setElememtToTable
(
self
,
table
:
QTableWidget
,
elem
:
Element
,
idx
:
int
):
def
setElememtToTable
(
self
,
table
:
QTableWidget
,
elem
:
Element
,
idx
:
int
):
elem_list
=
elem
.
to_list
()
elem_list
=
elem
.
to_list
()
if
table
.
objectName
()
==
"all_tableWidget"
:
if
table
.
objectName
()
==
constant
.
Content
.
ObjectName
:
elem_list
=
elem
.
to_short_list
()
elem_list
=
elem
.
to_short_list
()
for
j
in
range
(
len
(
elem_list
)):
for
j
in
range
(
len
(
elem_list
)):
item
=
QTableWidgetItem
(
elem_list
[
j
])
text
=
elem_list
[
j
]
if
type
(
text
)
==
str
and
'推荐'
in
text
:
text
=
text
[
text
.
index
(
'推荐'
):]
item
=
QTableWidgetItem
(
text
)
# 设置为不可编辑
# 设置为不可编辑
if
table
.
objectName
()
==
"all_tableWidget"
and
j
!=
constant
.
Content
.
ActivateColumn
:
if
self
.
checkIfTableItemCanChange
(
table
,
idx
,
j
)
==
False
:
item
.
setFlags
(
Qt
.
ItemIsEnabled
)
item
.
setFlags
(
Qt
.
ItemIsEnabled
)
table
.
setItem
(
idx
,
j
,
item
)
table
.
setItem
(
idx
,
j
,
item
)
# 只有Content页的字幕列和 Aside页的字幕列 可编辑
def
checkIfTableItemCanChange
(
self
,
table
:
QTableWidget
,
i
:
int
,
j
:
int
):
if
table
.
objectName
()
==
self
.
all_tableWidget
.
objectName
()
and
j
==
constant
.
Content
.
ActivateColumn
:
return
True
if
table
.
objectName
()
==
self
.
pb_tableWidget
.
objectName
()
and
j
==
constant
.
Aside
.
AsideColumnNumber
:
return
True
return
False
def
save_project
(
self
):
def
save_project
(
self
):
err_info
=
self
.
projectContext
.
save_project
()
err_info
=
self
.
projectContext
.
save_project
()
...
@@ -460,11 +496,21 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -460,11 +496,21 @@ class MainWindow(QMainWindow, Ui_MainWindow):
col
=
item
.
column
()
# 获取列数
col
=
item
.
column
()
# 获取列数
print
(
"row, col =
%
s,
%
s"
%
(
row
,
col
))
print
(
"row, col =
%
s,
%
s"
%
(
row
,
col
))
text
=
item
.
text
()
# 获取内容
text
=
item
.
text
()
# 获取内容
if
self
.
checkIfVideoTimeCanChange
(
row
,
col
):
self
.
player
.
setPosition
(
int
(
float
(
text
)
*
1000
))
self
.
player
.
setPosition
(
int
(
float
(
text
)
*
1000
))
def
checkIfVideoTimeCanChange
(
self
,
row
,
col
):
if
col
==
constant
.
Aside
.
StartTimeColumn
:
return
True
return
False
def
writeHistory
(
self
,
item
):
def
writeHistory
(
self
,
item
):
if
self
.
can_write_history
==
False
:
self
.
can_write_history
=
True
return
print
(
"writeHistory"
)
print
(
"writeHistory"
)
if
item
is
None
:
if
item
is
None
:
print
(
"WRONG!!!! item Is None"
)
print
(
"WRONG!!!! item Is None"
)
...
@@ -491,21 +537,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -491,21 +537,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
projectContext
.
history_push
(
row
,
text
,
text
)
self
.
projectContext
.
history_push
(
row
,
text
,
text
)
def
rewriteHistory
(
self
,
item
):
def
rewriteHistory
(
self
,
item
):
if
self
.
can_write_history
==
False
:
self
.
can_write_history
=
True
return
if
self
.
projectContext
.
initial_ing
==
True
:
return
print
(
"re writeHistory"
)
print
(
"re writeHistory"
)
if
item
is
None
:
if
item
is
None
:
print
(
"WRONG!!!! item Is None"
)
print
(
"WRONG!!!! item Is None"
)
return
return
else
:
else
:
row
=
item
.
row
()
# 获取行数
row
=
item
.
row
()
# 获取行数
col
=
item
.
column
()
# 获取列数 注意是column而不是col哦
col
=
item
.
column
()
# 获取列数 注意是column而不是col哦
text
=
item
.
text
()
# 获取内容
text
=
item
.
text
()
# 获取内容
opt
=
self
.
projectContext
.
history_pop
()
if
opt
==
None
:
# 刚打开表格的时候,会触发这个槽函数,此时opt肯定是None
return
if
col
!=
constant
.
Aside
.
AsideColumnNumber
:
if
col
!=
constant
.
Aside
.
AsideColumnNumber
:
return
return
opt
=
self
.
projectContext
.
history_pop
()
if
opt
==
None
:
# 刚打开表格的时候,会触发这个槽函数,此时opt肯定是None
return
# 抛出一个可能的异常
# 抛出一个可能的异常
if
row
!=
opt
.
row
:
if
row
!=
opt
.
row
:
print
(
"[rewriteHistory] Warning!!!row="
,
row
,
", old_row="
,
opt
.
row
,
", [row != opt.row]="
,
row
!=
opt
.
row
)
print
(
"[rewriteHistory] Warning!!!row="
,
row
,
", old_row="
,
opt
.
row
,
", [row != opt.row]="
,
row
!=
opt
.
row
)
...
@@ -522,6 +576,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -522,6 +576,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
row
=
item
.
row
()
# 获取行数
row
=
item
.
row
()
# 获取行数
col
=
item
.
column
()
# 获取列数 注意是column而不是col哦
col
=
item
.
column
()
# 获取列数 注意是column而不是col哦
text
=
item
.
text
()
# 获取内容
text
=
item
.
text
()
# 获取内容
if
col
!=
constant
.
Content
.
ActivateColumn
:
return
opt
=
self
.
projectContext
.
history_pop
()
opt
=
self
.
projectContext
.
history_pop
()
if
opt
==
None
:
# 刚打开表格的时候,会触发这个槽函数,此时opt肯定是None
if
opt
==
None
:
# 刚打开表格的时候,会触发这个槽函数,此时opt肯定是None
return
return
...
@@ -530,10 +588,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -530,10 +588,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
print
(
"Warning!!!row="
,
row
,
", old_row="
,
opt
.
row
)
print
(
"Warning!!!row="
,
row
,
", old_row="
,
opt
.
row
)
if
col
==
constant
.
Content
.
ActivateColumn
:
self
.
projectContext
.
history_push
(
opt
.
row
,
opt
.
old_str
,
text
)
self
.
projectContext
.
history_push
(
opt
.
row
,
opt
.
old_str
,
text
)
def
write2ProjectFromAside
(
self
,
item
):
def
write2ProjectFromAside
(
self
,
item
):
if
self
.
projectContext
.
initial_ing
==
True
:
return
print
(
"write2ProjectFromAside"
)
print
(
"write2ProjectFromAside"
)
if
item
is
None
:
if
item
is
None
:
print
(
"WRONG!!!! item Is None"
)
print
(
"WRONG!!!! item Is None"
)
...
@@ -546,6 +605,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -546,6 +605,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return
return
self
.
projectContext
.
refresh_aside
(
row
,
text
)
self
.
projectContext
.
refresh_aside
(
row
,
text
)
def
write2ProjectFromContent
(
self
,
item
):
def
write2ProjectFromContent
(
self
,
item
):
print
(
"write2ProjectFromContent"
)
print
(
"write2ProjectFromContent"
)
if
item
is
None
:
if
item
is
None
:
...
@@ -561,7 +621,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -561,7 +621,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
undo_slot
(
self
):
def
undo_slot
(
self
):
self
.
can_write_history
=
False
record
=
self
.
projectContext
.
history_pop
()
record
=
self
.
projectContext
.
history_pop
()
print
(
'[undo_slot] record=
%
s'
%
(
record
.
to_string
()))
print
(
'[undo_slot] record=
%
s'
%
(
record
.
to_string
()))
item
=
QTableWidgetItem
(
record
.
old_str
)
item
=
QTableWidgetItem
(
record
.
old_str
)
...
@@ -570,6 +630,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -570,6 +630,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
pb_tableWidget
.
setItem
(
row
,
constant
.
Aside
.
AsideColumnNumber
,
item
)
self
.
pb_tableWidget
.
setItem
(
row
,
constant
.
Aside
.
AsideColumnNumber
,
item
)
def
redo_slot
(
self
):
def
redo_slot
(
self
):
self
.
can_write_history
=
False
record
=
self
.
projectContext
.
history_redo
()
record
=
self
.
projectContext
.
history_redo
()
item
=
QTableWidgetItem
(
record
.
new_str
)
item
=
QTableWidgetItem
(
record
.
new_str
)
row
=
int
(
record
.
row
)
row
=
int
(
record
.
row
)
...
@@ -585,3 +646,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -585,3 +646,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
print
(
"pos:
%
d, history:
%
s"
%
(
i
,
self
.
projectContext
.
history_records
[
i
]
.
to_string
()))
print
(
"pos:
%
d, history:
%
s"
%
(
i
,
self
.
projectContext
.
history_records
[
i
]
.
to_string
()))
print
(
"=="
*
10
)
print
(
"=="
*
10
)
def
change_videotime_label_slot
(
self
):
if
self
.
player
.
duration
()
>
0
:
# 开始播放后才执行
self
.
change_videotime_label
()
self
.
change_table_select_rows
()
def
change_videotime_label
(
self
):
position
=
self
.
player
.
position
()
/
1000
duration
=
self
.
player
.
duration
()
/
1000
cur_time
=
utils
.
transfer_second_to_time
(
str
(
position
))[:
5
]
duration_time
=
utils
.
transfer_second_to_time
(
str
(
duration
))[:
5
]
self
.
label_2
.
setText
(
cur_time
+
"/"
+
duration_time
)
def
change_table_select_rows
(
self
):
cur_time
=
self
.
player
.
position
()
/
1000
all_elements
=
self
.
projectContext
.
all_elements
for
i
in
range
(
len
(
all_elements
)
-
1
,
-
1
,
-
1
):
if
utils
.
trans_to_seconds
(
all_elements
[
i
]
.
st_time_sec
)
<=
cur_time
:
self
.
all_tableWidget
.
selectRow
(
i
)
break
\ No newline at end of file
main_window.ui
View file @
54e9918a
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<item>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
stretch=
"5,1"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
stretch=
"5,1"
>
<item>
<item>
<layout
class=
"QHBoxLayout"
name=
"shuiping"
stretch=
"
3
,1"
>
<layout
class=
"QHBoxLayout"
name=
"shuiping"
stretch=
"
2
,1"
>
<item>
<item>
<widget
class=
"QWidget"
name=
"verticalWidget_3"
native=
"true"
>
<widget
class=
"QWidget"
name=
"verticalWidget_3"
native=
"true"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
stretch=
"8,0"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
stretch=
"8,0"
>
...
@@ -348,7 +348,7 @@ QPushButton:pressed {
...
@@ -348,7 +348,7 @@ QPushButton:pressed {
</sizepolicy>
</sizepolicy>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
字幕
时间轴
</string>
<string>
时间轴
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -416,7 +416,7 @@ QPushButton:pressed {
...
@@ -416,7 +416,7 @@ QPushButton:pressed {
</sizepolicy>
</sizepolicy>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
旁白时间轴
</string>
<string>
刻度
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -511,7 +511,7 @@ QPushButton:pressed {
...
@@ -511,7 +511,7 @@ QPushButton:pressed {
<widget
class=
"QStatusBar"
name=
"statusbar"
/>
<widget
class=
"QStatusBar"
name=
"statusbar"
/>
<action
name=
"actionxinjian"
>
<action
name=
"actionxinjian"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
新建
</string>
<string>
设置
</string>
</property>
</property>
</action>
</action>
<action
name=
"action_open_project"
>
<action
name=
"action_open_project"
>
...
...
main_window_ui.py
View file @
54e9918a
...
@@ -186,7 +186,7 @@ class Ui_MainWindow(object):
...
@@ -186,7 +186,7 @@ class Ui_MainWindow(object):
self
.
horizontalLayout_3
.
addWidget
(
self
.
pb_tableWidget
)
self
.
horizontalLayout_3
.
addWidget
(
self
.
pb_tableWidget
)
self
.
tabWidget
.
addTab
(
self
.
pb_tab
,
""
)
self
.
tabWidget
.
addTab
(
self
.
pb_tab
,
""
)
self
.
shuiping
.
addWidget
(
self
.
tabWidget
)
self
.
shuiping
.
addWidget
(
self
.
tabWidget
)
self
.
shuiping
.
setStretch
(
0
,
3
)
self
.
shuiping
.
setStretch
(
0
,
2
)
self
.
shuiping
.
setStretch
(
1
,
1
)
self
.
shuiping
.
setStretch
(
1
,
1
)
self
.
verticalLayout
.
addLayout
(
self
.
shuiping
)
self
.
verticalLayout
.
addLayout
(
self
.
shuiping
)
self
.
verticalWidget_2
=
QtWidgets
.
QWidget
(
self
.
centralwidget
)
self
.
verticalWidget_2
=
QtWidgets
.
QWidget
(
self
.
centralwidget
)
...
@@ -321,13 +321,13 @@ class Ui_MainWindow(object):
...
@@ -321,13 +321,13 @@ class Ui_MainWindow(object):
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
all_tab
),
_translate
(
"MainWindow"
,
"字幕旁白"
))
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
all_tab
),
_translate
(
"MainWindow"
,
"字幕旁白"
))
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
zm_tab
),
_translate
(
"MainWindow"
,
"字幕"
))
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
zm_tab
),
_translate
(
"MainWindow"
,
"字幕"
))
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
pb_tab
),
_translate
(
"MainWindow"
,
"旁白"
))
self
.
tabWidget
.
setTabText
(
self
.
tabWidget
.
indexOf
(
self
.
pb_tab
),
_translate
(
"MainWindow"
,
"旁白"
))
self
.
zm_label
.
setText
(
_translate
(
"MainWindow"
,
"
字幕
时间轴"
))
self
.
zm_label
.
setText
(
_translate
(
"MainWindow"
,
"时间轴"
))
self
.
lab_video
.
setText
(
_translate
(
"MainWindow"
,
"0
%
"
))
self
.
lab_video
.
setText
(
_translate
(
"MainWindow"
,
"0
%
"
))
self
.
pb_label
.
setText
(
_translate
(
"MainWindow"
,
"
旁白时间轴
"
))
self
.
pb_label
.
setText
(
_translate
(
"MainWindow"
,
"
刻度
"
))
self
.
menu
.
setTitle
(
_translate
(
"MainWindow"
,
"文件"
))
self
.
menu
.
setTitle
(
_translate
(
"MainWindow"
,
"文件"
))
self
.
menu_2
.
setTitle
(
_translate
(
"MainWindow"
,
"编辑"
))
self
.
menu_2
.
setTitle
(
_translate
(
"MainWindow"
,
"编辑"
))
self
.
menu_3
.
setTitle
(
_translate
(
"MainWindow"
,
"功能按键"
))
self
.
menu_3
.
setTitle
(
_translate
(
"MainWindow"
,
"功能按键"
))
self
.
actionxinjian
.
setText
(
_translate
(
"MainWindow"
,
"
新建
"
))
self
.
actionxinjian
.
setText
(
_translate
(
"MainWindow"
,
"
设置
"
))
self
.
action_open_project
.
setText
(
_translate
(
"MainWindow"
,
"打开"
))
self
.
action_open_project
.
setText
(
_translate
(
"MainWindow"
,
"打开"
))
self
.
import_movie
.
setText
(
_translate
(
"MainWindow"
,
"视频导入"
))
self
.
import_movie
.
setText
(
_translate
(
"MainWindow"
,
"视频导入"
))
self
.
actions
.
setText
(
_translate
(
"MainWindow"
,
"内容导出"
))
self
.
actions
.
setText
(
_translate
(
"MainWindow"
,
"内容导出"
))
...
...
management.py
View file @
54e9918a
...
@@ -2,10 +2,11 @@ import os.path
...
@@ -2,10 +2,11 @@ import os.path
import
threading
import
threading
import
traceback
import
traceback
import
sys
import
sys
import
json
from
enum
import
Enum
from
enum
import
Enum
import
datetime
import
datetime
import
openpyxl
import
openpyxl
import
constant
from
openpyxl.styles
import
PatternFill
,
Alignment
from
openpyxl.styles
import
PatternFill
,
Alignment
from
utils
import
replace_path_suffix
from
utils
import
replace_path_suffix
...
@@ -114,13 +115,23 @@ class ProjectContext:
...
@@ -114,13 +115,23 @@ class ProjectContext:
self
.
subtitle_list
=
[]
self
.
subtitle_list
=
[]
self
.
aside_list
=
[]
self
.
aside_list
=
[]
self
.
all_elements
=
[]
self
.
all_elements
=
[]
self
.
speaker_info
=
'晓辰,女,年轻人'
self
.
speaker_speed
=
'1.00(4字/秒)'
# 一些常量
# 一些常量
self
.
header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
]
self
.
header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"旁白"
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"旁白"
]
self
.
excel_sheet_name
=
"旁白插入位置建议"
self
.
excel_sheet_name
=
"旁白插入位置建议"
self
.
history_records
=
[]
self
.
history_records
=
[]
self
.
records_pos
=
0
self
.
records_pos
=
0
#是否处于初始化中
self
.
initial_ing
=
False
def
clear
(
self
):
self
.
subtitle_list
=
[]
self
.
aside_list
=
[]
self
.
all_elements
=
[]
self
.
history_records
=
[]
self
.
records_pos
=
0
def
Init
(
self
,
project_dir
,
video_name
):
def
Init
(
self
,
project_dir
,
video_name
):
self
.
project_base_dir
=
project_dir
self
.
project_base_dir
=
project_dir
# self.video_path = os.path.join(project_dir, video_name)
# self.video_path = os.path.join(project_dir, video_name)
...
@@ -151,9 +162,13 @@ class ProjectContext:
...
@@ -151,9 +162,13 @@ class ProjectContext:
def
refresh_aside
(
self
,
row
,
aside
:
str
)
->
None
:
def
refresh_aside
(
self
,
row
,
aside
:
str
)
->
None
:
self
.
aside_list
[
int
(
row
)]
.
aside
=
aside
self
.
aside_list
[
int
(
row
)]
.
aside
=
aside
if
not
self
.
initial_ing
:
save_excel_to_to_path
(
self
.
all_elements
,
self
.
excel_path
,
self
.
header
,
self
.
excel_sheet_name
)
def
refresh_element
(
self
,
row
,
aside
:
str
):
def
refresh_element
(
self
,
row
,
aside
:
str
):
self
.
all_elements
[
int
(
row
)]
.
aside
=
aside
self
.
all_elements
[
int
(
row
)]
.
aside
=
aside
if
not
self
.
initial_ing
:
save_excel_to_to_path
(
self
.
all_elements
,
self
.
excel_path
,
self
.
header
,
self
.
excel_sheet_name
)
# 加载整个工程,填充到ProjectContext上下文中
# 加载整个工程,填充到ProjectContext上下文中
def
load_project
(
self
):
def
load_project
(
self
):
...
@@ -161,7 +176,7 @@ class ProjectContext:
...
@@ -161,7 +176,7 @@ class ProjectContext:
def
load_excel_from_path
(
self
):
def
load_excel_from_path
(
self
):
d
=
read_sheet
(
self
.
excel_path
)
d
=
read_sheet
(
self
.
excel_path
)
self
.
all_elements
=
[]
self
.
clear
()
# todo:现在是只用None判断是否是字幕,后续是否也需要用""来?
# todo:现在是只用None判断是否是字幕,后续是否也需要用""来?
for
i
in
range
(
len
(
d
[
"字幕"
])):
for
i
in
range
(
len
(
d
[
"字幕"
])):
st_time_sec
,
ed_time_sec
,
subtitle
,
suggest
,
aside
=
[
d
[
x
][
i
]
for
x
in
self
.
header
]
st_time_sec
,
ed_time_sec
,
subtitle
,
suggest
,
aside
=
[
d
[
x
][
i
]
for
x
in
self
.
header
]
...
@@ -209,6 +224,18 @@ class ProjectContext:
...
@@ -209,6 +224,18 @@ class ProjectContext:
# 报错
# 报错
return
None
return
None
def
get_all_speaker_info
(
self
):
"""获取所有说话人的名字、性别及年龄段等信息
用于显示在人机交互界面上,方便用户了解说话人并进行选择
"""
f
=
open
(
constant
.
Pathes
.
speaker_conf_path
,
encoding
=
"utf-8"
)
content
=
json
.
load
(
f
)
speaker_name
=
[]
for
speaker
in
content
[
"speaker_details"
]:
speaker_name
.
append
(
","
.
join
([
speaker
[
"name"
],
speaker
[
"gender"
],
speaker
[
"age_group"
]]))
return
tuple
(
speaker_name
)
def
save_excel_to_to_path
(
all_element
,
new_excel_path
,
header
,
excel_sheet_name
):
def
save_excel_to_to_path
(
all_element
,
new_excel_path
,
header
,
excel_sheet_name
):
...
@@ -218,7 +245,7 @@ def save_excel_to_to_path(all_element, new_excel_path, header, excel_sheet_name)
...
@@ -218,7 +245,7 @@ def save_excel_to_to_path(all_element, new_excel_path, header, excel_sheet_name)
try
:
try
:
create_sheet
(
new_excel_path
,
"旁白插入位置建议"
,
[
header
])
create_sheet
(
new_excel_path
,
"旁白插入位置建议"
,
[
header
])
for
element
in
all_element
:
for
element
in
all_element
:
element
.
print_self
()
#
element.print_self()
write_to_sheet
(
new_excel_path
,
excel_sheet_name
,
element
.
to_list
())
write_to_sheet
(
new_excel_path
,
excel_sheet_name
,
element
.
to_list
())
except
:
except
:
exception_info
=
''
.
join
(
exception_info
=
''
.
join
(
...
...
setting_dialog.py
0 → 100644
View file @
54e9918a
import
sys
import
os
from
PyQt5.QtCore
import
*
;
from
PyQt5.QtGui
import
*
;
from
PyQt5.QtWidgets
import
*
;
from
setting_dialog_ui
import
Ui_Dialog
from
utils
import
validate_and_get_filepath
,
replace_path_suffix
class
Setting_Dialog
(
QDialog
,
Ui_Dialog
):
# 开始合成信号,传参分别是video_path,audio_dir, sheet_path,speed_info, caption_path, speaker_info
# 注意这里打包成一个list,在worker端进行解参数,避免传参过多
start_assemble_signal
=
pyqtSignal
(
list
)
def
__init__
(
self
,
projectContext
):
super
(
Setting_Dialog
,
self
)
.
__init__
()
self
.
setupUi
(
self
)
self
.
setWindowTitle
(
"合成"
)
self
.
projectContext
=
projectContext
# todo 把所有说话人都加上来
li
=
self
.
projectContext
.
get_all_speaker_info
()
for
i
in
li
:
self
.
comboBox
.
addItem
(
i
)
# self.comboBox.addItem('晓秋,女,年轻人')
self
.
comboBox_2
.
addItems
([
"1.00(4字/秒)"
,
"1.10(4.5字/秒)"
,
"1.25(5字/秒)"
,
"1.50(6字/秒)"
,
"1.75(7字/秒)"
,
"2.00(8字/秒)"
,
"2.50(10字/秒)"
])
self
.
comboBox
.
currentIndexChanged
.
connect
(
self
.
speaker_change_slot
)
self
.
comboBox_2
.
currentIndexChanged
.
connect
(
self
.
speed_change_slot
)
def
speaker_change_slot
(
self
):
self
.
projectContext
.
speaker_info
=
self
.
comboBox
.
currentText
()
print
(
"self.projectContext.speaker_info:"
,
self
.
projectContext
.
speaker_info
)
def
speed_change_slot
(
self
):
self
.
projectContext
.
speaker_speed
=
self
.
comboBox_2
.
currentText
()
if
__name__
==
'__main__'
:
app
=
QApplication
(
sys
.
argv
)
app
.
setWindowIcon
(
QIcon
(
"./images/eagle_2.ico"
))
dialog
=
Setting_Dialog
()
dialog
.
show
()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
setting_dialog.ui
0 → 100644
View file @
54e9918a
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
Dialog
</class>
<widget
class=
"QDialog"
name=
"Dialog"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
612
</width>
<height>
404
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Dialog
</string>
</property>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"geometry"
>
<rect>
<x>
30
</x>
<y>
140
</y>
<width>
111
</width>
<height>
16
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
旁白说话人:
</string>
</property>
</widget>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"geometry"
>
<rect>
<x>
30
</x>
<y>
200
</y>
<width>
111
</width>
<height>
16
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
旁白语速:
</string>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"comboBox"
>
<property
name=
"geometry"
>
<rect>
<x>
130
</x>
<y>
130
</y>
<width>
181
</width>
<height>
31
</height>
</rect>
</property>
<property
name=
"currentText"
>
<string/>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"comboBox_2"
>
<property
name=
"geometry"
>
<rect>
<x>
130
</x>
<y>
190
</y>
<width>
151
</width>
<height>
31
</height>
</rect>
</property>
<property
name=
"currentText"
>
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
setting_dialog_ui.py
0 → 100644
View file @
54e9918a
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'setting_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.12
#
# WARNING! All changes made in this file will be lost!
from
PyQt5
import
QtCore
,
QtGui
,
QtWidgets
class
Ui_Dialog
(
object
):
def
setupUi
(
self
,
Dialog
):
Dialog
.
setObjectName
(
"Dialog"
)
Dialog
.
resize
(
612
,
404
)
self
.
label_3
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_3
.
setGeometry
(
QtCore
.
QRect
(
30
,
140
,
111
,
16
))
self
.
label_3
.
setObjectName
(
"label_3"
)
self
.
label_4
=
QtWidgets
.
QLabel
(
Dialog
)
self
.
label_4
.
setGeometry
(
QtCore
.
QRect
(
30
,
200
,
111
,
16
))
self
.
label_4
.
setObjectName
(
"label_4"
)
self
.
comboBox
=
QtWidgets
.
QComboBox
(
Dialog
)
self
.
comboBox
.
setGeometry
(
QtCore
.
QRect
(
130
,
130
,
181
,
31
))
self
.
comboBox
.
setCurrentText
(
""
)
self
.
comboBox
.
setObjectName
(
"comboBox"
)
self
.
comboBox_2
=
QtWidgets
.
QComboBox
(
Dialog
)
self
.
comboBox_2
.
setGeometry
(
QtCore
.
QRect
(
130
,
190
,
151
,
31
))
self
.
comboBox_2
.
setCurrentText
(
""
)
self
.
comboBox_2
.
setObjectName
(
"comboBox_2"
)
self
.
retranslateUi
(
Dialog
)
QtCore
.
QMetaObject
.
connectSlotsByName
(
Dialog
)
def
retranslateUi
(
self
,
Dialog
):
_translate
=
QtCore
.
QCoreApplication
.
translate
Dialog
.
setWindowTitle
(
_translate
(
"Dialog"
,
"Dialog"
))
self
.
label_3
.
setText
(
_translate
(
"Dialog"
,
"旁白说话人:"
))
self
.
label_4
.
setText
(
_translate
(
"Dialog"
,
"旁白语速:"
))
start.py
View file @
54e9918a
import
sys
import
sys
import
traceback
from
PyQt5.QtCore
import
*
;
from
PyQt5.QtCore
import
*
;
from
PyQt5.QtGui
import
*
;
from
PyQt5.QtGui
import
*
;
from
PyQt5.QtWidgets
import
*
;
from
PyQt5.QtWidgets
import
*
;
...
@@ -8,8 +9,16 @@ from main_window import MainWindow
...
@@ -8,8 +9,16 @@ from main_window import MainWindow
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
app
=
QApplication
(
sys
.
argv
)
app
=
QApplication
(
sys
.
argv
)
app
.
setWindowIcon
(
QIcon
(
"./images/eagle_2.ico"
))
app
.
setWindowIcon
(
QIcon
(
"./images/eagle_2.ico"
))
mainWindow
=
MainWindow
()
mainWindow
=
MainWindow
()
mainWindow
.
show
()
mainWindow
.
show
()
sys
.
exit
(
app
.
exec_
())
sys
.
exit
(
app
.
exec_
())
except
Exception
as
e
:
exc_traceback
=
''
.
join
(
traceback
.
format_exception
(
*
sys
.
exc_info
()))
print
(
"[Catch Exception in start.py]"
,
exc_traceback
)
synthesis.py
View file @
54e9918a
...
@@ -14,6 +14,8 @@ class SynthesisProcessor(QWidget):
...
@@ -14,6 +14,8 @@ class SynthesisProcessor(QWidget):
synthesis_callback_signal
=
pyqtSignal
(
list
,
list
)
synthesis_callback_signal
=
pyqtSignal
(
list
,
list
)
def
__init__
(
self
):
def
__init__
(
self
):
super
(
SynthesisProcessor
,
self
)
.
__init__
()
super
(
SynthesisProcessor
,
self
)
.
__init__
()
self
.
state
=
[
None
]
self
.
threads
=
[]
# 对参数的加工放到processer这边
# 对参数的加工放到processer这边
def
synthesis_slot
(
self
,
param
:
list
):
def
synthesis_slot
(
self
,
param
:
list
):
...
@@ -70,7 +72,8 @@ class SynthesisProcessor(QWidget):
...
@@ -70,7 +72,8 @@ class SynthesisProcessor(QWidget):
# 多线程同时实现语音合成+字幕导出、进度条
# 多线程同时实现语音合成+字幕导出、进度条
state
=
[
None
]
state
=
[
None
]
threads
=
[]
threads
=
[]
self
.
state
=
state
self
.
threads
=
threads
from
speech_synthesis
import
ss_and_export
from
speech_synthesis
import
ss_and_export
t
=
RunThread
(
funcName
=
ss_and_export
,
t
=
RunThread
(
funcName
=
ss_and_export
,
args
=
(
video_path
,
sheet_path
,
audio_dir
,
speed
,
args
=
(
video_path
,
sheet_path
,
audio_dir
,
speed
,
...
@@ -89,29 +92,29 @@ class SynthesisProcessor(QWidget):
...
@@ -89,29 +92,29 @@ class SynthesisProcessor(QWidget):
print
(
"===子线程已经开启 in synthesis==="
)
print
(
"===子线程已经开启 in synthesis==="
)
self
.
synthesis_callback_signal
.
emit
(
threads
)
self
.
synthesis_callback_signal
.
emit
(
threads
,
state
)
# 查询线程是否有结束的,一旦一个结束,另一个也结束
# 查询线程是否有结束的,一旦一个结束,另一个也结束
while
1
:
#
while 1:
alive
=
True
#
alive = True
for
t
in
threads
:
#
for t in threads:
alive
=
alive
and
t
.
is_alive
()
#
alive = alive and t.is_alive()
if
not
alive
:
#
if not alive:
break
#
break
time
.
sleep
(
5
)
#
time.sleep(5)
print
(
"===已有线程结束了 in synthesis==="
)
#
print("===已有线程结束了 in synthesis===")
for
t
in
threads
:
#
for t in threads:
if
t
.
exitcode
!=
0
:
#
if t.exitcode != 0:
print
(
"Exception in"
,
t
.
getName
())
#
print("Exception in", t.getName())
self
.
show_warning_signal
.
emit
(
"运行出错,请联系开发者处理"
)
#
self.show_warning_signal.emit("运行出错,请联系开发者处理")
# processState_2.set("任务中断")
#
# processState_2.set("任务中断")
# progress_state = progressbar_2['value']
#
# progress_state = progressbar_2['value']
# progressbar_2.stop()
#
# progressbar_2.stop()
# progressbar_2['value'] = progress_state
#
# progressbar_2['value'] = progress_state
# startSynthesis.config(state=tk.ACTIVE)
#
# startSynthesis.config(state=tk.ACTIVE)
# stopSynthesis.config(state=tk.DISABLED)
#
# stopSynthesis.config(state=tk.DISABLED)
return
#
return
#
print
(
"合成任务完成"
)
#
print("合成任务完成")
# processState_2.set("任务完成")
# processState_2.set("任务完成")
# progressbar_2.stop()
# progressbar_2.stop()
# progressbar_2['value'] = 100.0
# progressbar_2['value'] = 100.0
...
...
test37second.xlsx
View file @
54e9918a
No preview for this file type
testTableWidget.py
View file @
54e9918a
...
@@ -27,8 +27,8 @@ class TableWidget(QWidget):
...
@@ -27,8 +27,8 @@ class TableWidget(QWidget):
tablewidget
.
setItem
(
0
,
1
,
ageItem
)
tablewidget
.
setItem
(
0
,
1
,
ageItem
)
jgItem
=
QTableWidgetItem
(
"北京"
)
jgItem
=
QTableWidgetItem
(
"北京"
)
#
jgItem.setFlags(Qt.ItemIsEnabled)
jgItem
.
setFlags
(
Qt
.
ItemIsEnabled
)
jgItem
.
setFlags
(
Qt
.
ItemFlags
(
32
))
#
jgItem.setFlags(Qt.ItemFlags(32))
# jgItem.checkState()
# jgItem.checkState()
tablewidget
.
setItem
(
0
,
2
,
jgItem
)
tablewidget
.
setItem
(
0
,
2
,
jgItem
)
self
.
tablewidget
=
tablewidget
self
.
tablewidget
=
tablewidget
...
...
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