Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -99,44 +99,43 @@ def create_video(images, durations, audio_path):
|
|
99 |
output_path = os.path.join(tempfile.gettempdir(), "final_video.mp4")
|
100 |
video.write_videofile(output_path, fps=1, codec='libx264')
|
101 |
return output_path
|
102 |
-
|
103 |
def process_pipeline(prompt, progress=gr.Progress()):
|
104 |
try:
|
105 |
-
|
106 |
-
|
107 |
-
step = 0
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
|
133 |
-
|
134 |
|
135 |
return video_path
|
136 |
except Exception as e:
|
137 |
print(f"Error in process_pipeline: {str(e)}")
|
138 |
raise gr.Error(f"An error occurred: {str(e)}")
|
139 |
-
|
140 |
title = """<h1 align="center">AI Story Video Generator ๐ฅ</h1>
|
141 |
<p align="center">
|
142 |
Generate a story from a prompt, create images for each sentence, and produce a video with narration!
|
|
|
99 |
output_path = os.path.join(tempfile.gettempdir(), "final_video.mp4")
|
100 |
video.write_videofile(output_path, fps=1, codec='libx264')
|
101 |
return output_path
|
102 |
+
|
103 |
def process_pipeline(prompt, progress=gr.Progress()):
|
104 |
try:
|
105 |
+
total_steps = 6
|
106 |
+
step = 0
|
|
|
107 |
|
108 |
+
progress(step / total_steps, desc="Generating Story")
|
109 |
+
story = generate_story(prompt)
|
110 |
+
step += 1
|
111 |
|
112 |
+
progress(step / total_steps, desc="Splitting Story into Sentences")
|
113 |
+
sentences = split_story_into_sentences(story)
|
114 |
+
step += 1
|
115 |
|
116 |
+
progress(step / total_steps, desc="Generating Images for Sentences")
|
117 |
+
images = generate_images(sentences)
|
118 |
+
step += 1
|
119 |
|
120 |
+
progress(step / total_steps, desc="Generating Audio")
|
121 |
+
audio_path, total_duration = generate_audio(story)
|
122 |
+
step += 1
|
123 |
|
124 |
+
progress(step / total_steps, desc="Computing Durations")
|
125 |
+
durations = compute_sentence_durations(sentences, total_duration)
|
126 |
+
step += 1
|
127 |
|
128 |
+
progress(step / total_steps, desc="Creating Video")
|
129 |
+
video_path = create_video(images, durations, audio_path)
|
130 |
+
step += 1
|
131 |
|
132 |
+
progress(1.0, desc="Completed")
|
133 |
|
134 |
return video_path
|
135 |
except Exception as e:
|
136 |
print(f"Error in process_pipeline: {str(e)}")
|
137 |
raise gr.Error(f"An error occurred: {str(e)}")
|
138 |
+
|
139 |
title = """<h1 align="center">AI Story Video Generator ๐ฅ</h1>
|
140 |
<p align="center">
|
141 |
Generate a story from a prompt, create images for each sentence, and produce a video with narration!
|