BoldActionMan
commited on
Commit
•
d90eff5
1
Parent(s):
caa4e19
Update app.py
Browse files
app.py
CHANGED
@@ -169,22 +169,22 @@ def process_video(video_file, language_choice):
|
|
169 |
segment_files = []
|
170 |
subtitle_entries = []
|
171 |
for i in range(0, len(translation_segments), batch_size):
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
|
189 |
# Combine the audio segments
|
190 |
combined_audio = AudioSegment.empty()
|
|
|
169 |
segment_files = []
|
170 |
subtitle_entries = []
|
171 |
for i in range(0, len(translation_segments), batch_size):
|
172 |
+
batch = translation_segments[i:i + batch_size]
|
173 |
+
with ThreadPoolExecutor(max_workers=5) as executor:
|
174 |
+
batch_segment_files = list(executor.map(generate_segment_audio_batch, [batch] * len(speaker_ids), [speaker_id] * len(speaker_ids)))
|
175 |
+
batch_segment_files = [item for sublist in batch_segment_files for item in sublist] # Flatten the list
|
176 |
+
|
177 |
+
for segment_file, start, end, translated_text in batch_segment_files:
|
178 |
+
# Run the tone color converter
|
179 |
+
encode_message = "@MyShell"
|
180 |
+
tone_color_converter.convert(
|
181 |
+
audio_src_path=segment_file,
|
182 |
+
src_se=source_se,
|
183 |
+
tgt_se=target_se,
|
184 |
+
output_path=segment_file,
|
185 |
+
message=encode_message
|
186 |
+
)
|
187 |
+
segment_files.append((segment_file, start, end, translated_text))
|
188 |
|
189 |
# Combine the audio segments
|
190 |
combined_audio = AudioSegment.empty()
|