Spaces:
Sleeping
Sleeping
Update pipeline/pipeline.py
Browse files- pipeline/pipeline.py +50 -49
pipeline/pipeline.py
CHANGED
|
@@ -1,49 +1,50 @@
|
|
| 1 |
-
# pipeline.py
|
| 2 |
-
import asyncio
|
| 3 |
-
import logging
|
| 4 |
-
from api.server import pending_confirmations # Access the confirmation events
|
| 5 |
-
|
| 6 |
-
# Import your modules
|
| 7 |
-
import core.script_gen as script_gen
|
| 8 |
-
import core.story_script as story_script
|
| 9 |
-
# import core.image_gen as image_gen
|
| 10 |
-
# import core.video_gen as video_gen
|
| 11 |
-
# import core.music_gen as music_gen
|
| 12 |
-
# import core.assemble as assemble
|
| 13 |
-
|
| 14 |
-
logging.basicConfig(
|
| 15 |
-
level=logging.INFO,
|
| 16 |
-
format="%(asctime)s [%(levelname)s] %(message)s"
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
async def run_pipeline(task: dict):
|
| 20 |
-
task_id = task["task_id"]
|
| 21 |
-
idea = task["idea"]
|
| 22 |
-
|
| 23 |
-
logging.info(f"[Pipeline] Starting script generation for task {task_id}")
|
| 24 |
-
script = await script_gen.generate_script(idea) # Async script generation
|
| 25 |
-
|
| 26 |
-
logging.info(f"[Pipeline] Waiting for user confirmation for task {task_id}")
|
| 27 |
-
# Wait for confirmation (manual or auto)
|
| 28 |
-
if task_id in pending_confirmations:
|
| 29 |
-
await pending_confirmations[task_id].wait()
|
| 30 |
-
else:
|
| 31 |
-
logging.info(f"[Pipeline] No pending confirmation found, auto-confirming task {task_id}")
|
| 32 |
-
|
| 33 |
-
logging.info(f"[Pipeline] Generating story script for task {task_id}")
|
| 34 |
-
story = await story_script.generate_story(script)
|
| 35 |
-
final_output = story # Placeholder for final output
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# video
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# audio
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
| 1 |
+
# pipeline.py
|
| 2 |
+
import asyncio
|
| 3 |
+
import logging
|
| 4 |
+
from api.server import pending_confirmations # Access the confirmation events
|
| 5 |
+
|
| 6 |
+
# Import your modules
|
| 7 |
+
import core.script_gen as script_gen
|
| 8 |
+
import core.story_script as story_script
|
| 9 |
+
# import core.image_gen as image_gen
|
| 10 |
+
# import core.video_gen as video_gen
|
| 11 |
+
# import core.music_gen as music_gen
|
| 12 |
+
# import core.assemble as assemble
|
| 13 |
+
|
| 14 |
+
logging.basicConfig(
|
| 15 |
+
level=logging.INFO,
|
| 16 |
+
format="%(asctime)s [%(levelname)s] %(message)s"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
async def run_pipeline(task: dict):
|
| 20 |
+
task_id = task["task_id"]
|
| 21 |
+
idea = task["idea"]
|
| 22 |
+
|
| 23 |
+
logging.info(f"[Pipeline] Starting script generation for task {task_id}")
|
| 24 |
+
script = await script_gen.generate_script(idea) # Async script generation
|
| 25 |
+
|
| 26 |
+
logging.info(f"[Pipeline] Waiting for user confirmation for task {task_id}")
|
| 27 |
+
# Wait for confirmation (manual or auto)
|
| 28 |
+
if task_id in pending_confirmations:
|
| 29 |
+
await pending_confirmations[task_id].wait()
|
| 30 |
+
else:
|
| 31 |
+
logging.info(f"[Pipeline] No pending confirmation found, auto-confirming task {task_id}")
|
| 32 |
+
|
| 33 |
+
logging.info(f"[Pipeline] Generating story script for task {task_id}")
|
| 34 |
+
story = await story_script.generate_story(script)
|
| 35 |
+
# final_output = story # Placeholder for final output
|
| 36 |
+
logging.info(f"[Pipeline] Generating images for task {task_id}")
|
| 37 |
+
images = await image_gen.generate_images(story)
|
| 38 |
+
final_output=images
|
| 39 |
+
|
| 40 |
+
# logging.info(f"[Pipeline] Generating video for task {task_id}")
|
| 41 |
+
# video = await video_gen.generate_video(images)
|
| 42 |
+
|
| 43 |
+
# logging.info(f"[Pipeline] Generating music/audio for task {task_id}")
|
| 44 |
+
# audio = await music_gen.generate_music(story)
|
| 45 |
+
|
| 46 |
+
# logging.info(f"[Pipeline] Assembling final output for task {task_id}")
|
| 47 |
+
# final_output = await assemble.create_final(video, audio)
|
| 48 |
+
|
| 49 |
+
logging.info(f"[Pipeline] Task {task_id} completed. Output: {final_output}")
|
| 50 |
+
return final_output
|