Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,33 +100,38 @@ def create_video(images, durations, audio_path):
|
|
| 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 |
-
with progress
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
story = generate_story(prompt)
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
sentences = split_story_into_sentences(story)
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
images = generate_images(sentences)
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
audio_path, total_duration = generate_audio(story)
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
durations = compute_sentence_durations(sentences, total_duration)
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
video_path = create_video(images, durations, audio_path)
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
return video_path
|
| 131 |
except Exception as e:
|
| 132 |
print(f"Error in process_pipeline: {str(e)}")
|
|
|
|
| 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 |
+
with progress:
|
| 106 |
+
total_steps = 6
|
| 107 |
+
step = 0
|
| 108 |
+
|
| 109 |
+
progress(step / total_steps, desc="Generating Story")
|
| 110 |
story = generate_story(prompt)
|
| 111 |
+
step += 1
|
| 112 |
+
|
| 113 |
+
progress(step / total_steps, desc="Splitting Story into Sentences")
|
| 114 |
sentences = split_story_into_sentences(story)
|
| 115 |
+
step += 1
|
| 116 |
+
|
| 117 |
+
progress(step / total_steps, desc="Generating Images for Sentences")
|
| 118 |
images = generate_images(sentences)
|
| 119 |
+
step += 1
|
| 120 |
+
|
| 121 |
+
progress(step / total_steps, desc="Generating Audio")
|
| 122 |
audio_path, total_duration = generate_audio(story)
|
| 123 |
+
step += 1
|
| 124 |
+
|
| 125 |
+
progress(step / total_steps, desc="Computing Durations")
|
| 126 |
durations = compute_sentence_durations(sentences, total_duration)
|
| 127 |
+
step += 1
|
| 128 |
+
|
| 129 |
+
progress(step / total_steps, desc="Creating Video")
|
| 130 |
video_path = create_video(images, durations, audio_path)
|
| 131 |
+
step += 1
|
| 132 |
+
|
| 133 |
+
progress(1.0, desc="Completed")
|
| 134 |
+
|
| 135 |
return video_path
|
| 136 |
except Exception as e:
|
| 137 |
print(f"Error in process_pipeline: {str(e)}")
|