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
41a6db21
Commit
41a6db21
authored
Sep 30, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd:[预览旁白音频]功能改为异步
parent
4ea53be6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
19 deletions
+25
-19
conf.ini
conf.ini
+2
-2
main_window.py
main_window.py
+8
-7
main_window.ui
main_window.ui
+6
-0
main_window_ui.py
main_window_ui.py
+2
-0
management.py
management.py
+2
-2
speech_synthesis.py
speech_synthesis.py
+5
-8
No files found.
conf.ini
View file @
41a6db21
云扬,男,年轻人
2.50(10字/秒)
\ No newline at end of file
1.00(4字/秒)
\ No newline at end of file
main_window.py
View file @
41a6db21
...
...
@@ -387,8 +387,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 0、视频必须在播放中
if
self
.
is_video_playing
==
False
:
return
# 1、先找到要播放的音频
st
=
time
.
time
()
# 1、先找到要播放的音频
(一个电影最多2000条字幕或旁白)
# todo: 验证2k条的旁白,O(n)找到待播放音频,会不会很慢
audio_path
=
None
for
i
in
range
(
len
(
self
.
projectContext
.
aside_list
)
-
1
,
-
1
,
-
1
):
if
position
/
1000
>
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
):
...
...
@@ -399,8 +399,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
RunThread
(
funcName
=
self
.
play_audio
,
args
=
(
audio_path
,
self
.
previewed_audio
),
name
=
"play_audio"
)
.
start
()
ed
=
time
.
time
()
print
(
"耗时:
%.2
fs"
%
(
ed
-
st
))
@staticmethod
#一条语音的最长播放时间是10秒
...
...
@@ -475,8 +473,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
header
=
self
.
projectContext
.
header
subtitle_list
=
self
.
projectContext
.
subtitle_list
aside_list
=
self
.
projectContext
.
aside_list
print
(
"sublist"
,
subtitle_list
)
print
(
"aside_list"
,
aside_list
)
all_elements
=
self
.
projectContext
.
all_elements
contentHeader
=
self
.
projectContext
.
contentHeader
...
...
@@ -603,7 +599,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
speed
=
float
(
speed_info
.
split
(
'('
)[
0
])
speaker_name
=
speaker_info
.
split
(
","
)[
0
]
speaker
=
self
.
projectContext
.
choose_speaker
(
speaker_name
)
speech_synthesis
(
item
.
text
(),
wav_path
,
speaker
,
speed
)
t
=
RunThread
(
funcName
=
speech_synthesis
,
args
=
(
item
.
text
(),
wav_path
,
speaker
,
speed
),
name
=
"speech_synthesis"
)
t
.
setDaemon
(
True
)
t
.
start
()
if
self
.
can_write_history
==
False
:
self
.
can_write_history
=
True
...
...
main_window.ui
View file @
41a6db21
...
...
@@ -471,6 +471,12 @@ QPushButton:pressed {
<property
name=
"focusPolicy"
>
<enum>
Qt::NoFocus
</enum>
</property>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
<property
name=
"maximum"
>
<number>
100
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
...
...
main_window_ui.py
View file @
41a6db21
...
...
@@ -250,6 +250,8 @@ class Ui_MainWindow(object):
self
.
kd_slider
.
setCursor
(
QtGui
.
QCursor
(
QtCore
.
Qt
.
SizeHorCursor
))
self
.
kd_slider
.
setMouseTracking
(
False
)
self
.
kd_slider
.
setFocusPolicy
(
QtCore
.
Qt
.
NoFocus
)
self
.
kd_slider
.
setMinimum
(
1
)
self
.
kd_slider
.
setMaximum
(
100
)
self
.
kd_slider
.
setOrientation
(
QtCore
.
Qt
.
Horizontal
)
self
.
kd_slider
.
setTickPosition
(
QtWidgets
.
QSlider
.
TicksAbove
)
self
.
kd_slider
.
setTickInterval
(
1
)
...
...
management.py
View file @
41a6db21
...
...
@@ -220,8 +220,8 @@ class ProjectContext:
ed_time_sec
=
"
%.2
f"
%
(
float
(
d
[
"起始时间"
][
i
+
1
])
-
0.01
)
self
.
aside_list
.
append
(
Element
(
st_time_sec
,
ed_time_sec
,
subtitle
,
suggest
,
aside
))
self
.
all_elements
.
append
(
self
.
aside_list
[
-
1
])
print
(
"[load_excel_from_path] "
,
end
=
''
)
self
.
all_elements
[
-
1
]
.
print_self
()
#
print("[load_excel_from_path] ", end='')
#
self.all_elements[-1].print_self()
# 现在仅支持对修改操作的记录
def
history_push
(
self
,
row
,
old
,
new
):
if
self
.
records_pos
==
len
(
self
.
history_records
):
...
...
speech_synthesis.py
View file @
41a6db21
...
...
@@ -82,17 +82,14 @@ def choose_speaker(speaker_name: str) -> Speaker:
def
speech_synthesis
(
text
:
str
,
output_file
:
str
,
speaker
:
Speaker
,
speed
:
float
=
1.0
):
"""用于合成讲解音频并输出
分为两步走:第一步在项目文件夹生成tmp.wav;第二步在output_file路径下生成调整音量和语速后的音频
Args:
text (str): 解说文本
output_file (str): 输出文件路径
speaker (Speaker): 说话人
speed (float, optional): 指定的音频语速. Defaults to 1.0.
"""
if
float
(
speed
)
!=
1.0
:
audio_path
=
tmp_file
else
:
audio_path
=
output_file
audio_path
=
tmp_file
speech_config
=
SpeechConfig
(
subscription
=
"ffa331815f0f4c7fa418bb6c2e1c4e17"
,
region
=
"eastus"
)
...
...
@@ -100,9 +97,9 @@ def speech_synthesis(text: str, output_file: str, speaker: Speaker, speed: float
speech_config
.
speech_synthesis_voice_name
=
speaker
.
speaker_code
# 先把合成的语音文件输出得到tmp.wav中,便于可能的调速需求
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
audio_path
)):
# 如果路径不存在
print
(
"
路径不存在,创建:"
,
os
.
path
.
dirname
(
audio_path
))
os
.
makedirs
(
os
.
path
.
dirname
(
audio_path
))
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
output_file
)):
# 如果路径不存在
print
(
"
output_file路径不存在,创建:"
,
os
.
path
.
dirname
(
output_file
))
os
.
makedirs
(
os
.
path
.
dirname
(
output_file
))
audio_config
=
AudioOutputConfig
(
filename
=
audio_path
)
synthesizer
=
SpeechSynthesizer
(
speech_config
=
speech_config
,
audio_config
=
audio_config
)
...
...
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