Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,9 +35,15 @@ def generate_voice_from_text(text, query,lang='en'):
|
|
35 |
tts = gTTS(text=text, lang=lang)
|
36 |
audio_path = f'temp_{query}_audio.mp3'
|
37 |
tts.save(audio_path)
|
|
|
38 |
return audio_path
|
39 |
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
def read_script(content):
|
43 |
"""Reads a script file and returns a list of text and queries."""
|
@@ -81,6 +87,7 @@ def process_segment(text, query, index):
|
|
81 |
loop_count = int( audio_clip.duration// video_clip.duration)
|
82 |
video_clip = mpe.concatenate_videoclips([video_clip] * loop_count)
|
83 |
|
|
|
84 |
# Combine the audio and video
|
85 |
final_clip = video_clip.set_audio(audio_clip)
|
86 |
|
@@ -88,6 +95,8 @@ def process_segment(text, query, index):
|
|
88 |
video_file_path = f"{query}_{index}.mp4" # Removed the redundant assignment here
|
89 |
|
90 |
final_clip.write_videofile(video_file_path, codec="libx264", fps=24)
|
|
|
|
|
91 |
return video_file_path
|
92 |
else:
|
93 |
print(f"Skipping segment due to no available video for query: {query}")
|
@@ -117,6 +126,8 @@ def process_video_paragraph(text):
|
|
117 |
final_output_path = "final_concatenated_video.mp4"
|
118 |
final_video.write_videofile(final_output_path, codec="libx264", fps=24)
|
119 |
print(f"Final concatenated video created: {final_output_path}")
|
|
|
|
|
120 |
return final_output_path
|
121 |
|
122 |
|
|
|
35 |
tts = gTTS(text=text, lang=lang)
|
36 |
audio_path = f'temp_{query}_audio.mp3'
|
37 |
tts.save(audio_path)
|
38 |
+
save_and_return_file(audio_path)
|
39 |
return audio_path
|
40 |
|
41 |
|
42 |
+
def save_and_return_file(text):
|
43 |
+
# Write some text to a file
|
44 |
+
with open(filename, "w") as file:
|
45 |
+
file.write(text)
|
46 |
+
|
47 |
|
48 |
def read_script(content):
|
49 |
"""Reads a script file and returns a list of text and queries."""
|
|
|
87 |
loop_count = int( audio_clip.duration// video_clip.duration)
|
88 |
video_clip = mpe.concatenate_videoclips([video_clip] * loop_count)
|
89 |
|
90 |
+
|
91 |
# Combine the audio and video
|
92 |
final_clip = video_clip.set_audio(audio_clip)
|
93 |
|
|
|
95 |
video_file_path = f"{query}_{index}.mp4" # Removed the redundant assignment here
|
96 |
|
97 |
final_clip.write_videofile(video_file_path, codec="libx264", fps=24)
|
98 |
+
save_and_return_file(video_file_path)
|
99 |
+
|
100 |
return video_file_path
|
101 |
else:
|
102 |
print(f"Skipping segment due to no available video for query: {query}")
|
|
|
126 |
final_output_path = "final_concatenated_video.mp4"
|
127 |
final_video.write_videofile(final_output_path, codec="libx264", fps=24)
|
128 |
print(f"Final concatenated video created: {final_output_path}")
|
129 |
+
save_and_return_file(final_output_path)
|
130 |
+
|
131 |
return final_output_path
|
132 |
|
133 |
|