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
b0e34ce2
Commit
b0e34ce2
authored
Nov 12, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增单条预览的功能
parent
a41348f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
5 deletions
+50
-5
constant.py
constant.py
+1
-0
main_window.py
main_window.py
+46
-2
management.py
management.py
+3
-3
No files found.
constant.py
View file @
b0e34ce2
...
...
@@ -15,6 +15,7 @@ class Aside:
ActivateColumns
=
[
3
,
4
]
ObjectName
=
"pb_tableWidget"
TimeFormatColumns
=
[
0
,
1
]
PreviewColumnNumber
=
5
class
Subtitle
:
ObjectName
=
"zm_tableWidget"
...
...
main_window.py
View file @
b0e34ce2
...
...
@@ -5,8 +5,8 @@ import cv2
import
qtawesome
from
PyQt5
import
QtWidgets
from
PyQt5.QtWidgets
import
QMainWindow
,
QFileDialog
,
QTableWidget
,
QTableWidgetItem
,
QAbstractItemView
,
QProgressBar
,
QLabel
,
QApplication
from
PyQt5.QtCore
import
QUrl
,
Qt
,
QTimer
,
QRect
,
pyqtSignal
from
PyQt5.QtWidgets
import
QMainWindow
,
QFileDialog
,
QTableWidget
,
QTableWidgetItem
,
QAbstractItemView
,
QProgressBar
,
QLabel
,
QApplication
,
QPushButton
from
PyQt5.QtCore
import
QUrl
,
Qt
,
QTimer
,
QRect
,
pyqtSignal
,
QPersistentModelIndex
from
PyQt5.QtMultimedia
import
*
from
PyQt5.QtGui
import
QIcon
import
utils
...
...
@@ -711,6 +711,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
user_operation=True的情况:用户双击操作表格,通过【操作表格】进行增删改,通过【在此处添加旁白】来添加一行
initial_ing为true时,不会生成音频,不会写入历史记录
"""
print
(
"set一次"
)
if
not
user_operation
:
self
.
projectContext
.
initial_ing
=
True
subtitle_list
=
self
.
projectContext
.
subtitle_list
...
...
@@ -757,6 +758,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if
table
.
objectName
()
==
constant
.
Aside
.
ObjectName
:
elem_list
=
elem
.
to_aside_list
()
time_format_col_list
=
constant
.
Aside
.
TimeFormatColumns
btn
=
QPushButton
()
btn
.
setText
(
f
"预览{idx}"
)
col
=
len
(
elem_list
)
btn
.
clicked
.
connect
(
self
.
btn_pressed_preview_audio_slot
)
table
.
setCellWidget
(
idx
,
col
,
btn
)
for
j
in
range
(
len
(
elem_list
)):
text
=
elem_list
[
j
]
...
...
@@ -773,6 +780,43 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 只有Content页的字幕列和 Aside页的字幕列 可编辑
def
btn_pressed_preview_audio_slot
(
self
):
btn
=
self
.
sender
()
# 法1:按照物理位置。这样的结果不太对
# index = self.pb_tableWidget.indexAt(btn.pos())
# print("index:", index.row())
# 法2:遍历所有button,比较是否是同一对象。注意sender不能强转成btn类型,这样就变成新对象了
idx
=
0
for
i
in
range
(
self
.
pb_tableWidget
.
rowCount
()):
if
id
(
self
.
pb_tableWidget
.
cellWidget
(
i
,
constant
.
Aside
.
PreviewColumnNumber
))
==
id
(
btn
):
idx
=
i
break
item
=
self
.
pb_tableWidget
.
item
(
idx
,
0
)
print
(
"当前起始时间:"
,
item
.
text
())
print
(
"index:"
,
idx
)
audio_path
=
None
pos_sec
=
utils
.
trans_to_seconds
(
item
.
text
())
for
i
in
range
(
len
(
self
.
projectContext
.
aside_list
)
-
1
,
-
1
,
-
1
):
# print(f"pos_sec:{pos_sec}, st_time_sec:{float(self.projectContext.aside_list[i].st_time_sec)}")
if
pos_sec
>=
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
):
audio_path
=
os
.
path
.
dirname
(
self
.
projectContext
.
excel_path
)
+
(
"/tmp/
%.2
f.wav"
%
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
))
break
# 2、如果找到了该音频,则新起一个线程播放
if
audio_path
!=
None
and
os
.
path
.
exists
(
audio_path
):
t
=
RunThread
(
funcName
=
self
.
play_audio
,
args
=
(
audio_path
,
self
.
previewed_audio
),
name
=
"play_audio"
)
t
.
start
()
self
.
all_threads
.
append
(
t
)
self
.
player
.
setPosition
(
int
(
pos_sec
*
1000
))
# 做播放视频的操作,绑定播放按钮的变化
self
.
is_video_playing
=
False
self
.
playVideo
()
else
:
self
.
prompt_dialog
.
show_with_msg
(
"暂无音频可供预览,请重新生成"
)
def
checkIfTableItemCanChange
(
self
,
table
:
QTableWidget
,
i
:
int
,
j
:
int
):
# if table.objectName() == self.all_tableWidget.objectName() and j in constant.Content.ActivateColumns:
# return True
...
...
management.py
View file @
b0e34ce2
...
...
@@ -121,10 +121,10 @@ class ProjectContext:
self
.
speaker_speed
=
None
# 一些常量
self
.
header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
'建议'
,
'解说脚本'
,
"语速"
]
self
.
aside_header
=
[
"起始时间"
,
"终止时间"
,
'推荐插入字数'
,
'解说脚本'
,
"语速"
,
""
]
self
.
subtitle_header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
,
""
]
self
.
aside_header
=
[
"起始时间"
,
"终止时间"
,
'推荐插入字数'
,
'解说脚本'
,
"语速"
,
"
预览音频
"
]
self
.
subtitle_header
=
[
"起始时间"
,
"终止时间"
,
"字幕"
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"解说脚本"
,
"语速"
,
""
]
self
.
contentHeader
=
[
"起始时间"
,
"字幕"
,
"解说脚本"
,
"语速"
]
self
.
excel_sheet_name
=
"旁白插入位置建议"
self
.
history_records
=
[]
self
.
records_pos
=
0
...
...
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