ladybug11 commited on
Commit
14d2c66
·
1 Parent(s): 517d6fb

back to 6 grid

Browse files
Files changed (1) hide show
  1. app.py +50 -29
app.py CHANGED
@@ -526,7 +526,7 @@ def get_voice_config(voice_profile: str) -> Tuple[str, VoiceSettings]:
526
 
527
  if "rachel" in vp or "female" in vp:
528
  return (
529
- "21m00Tcm4TlvDq8ikWAM",
530
  VoiceSettings(
531
  stability=0.5,
532
  similarity_boost=0.9,
@@ -536,7 +536,7 @@ def get_voice_config(voice_profile: str) -> Tuple[str, VoiceSettings]:
536
  )
537
 
538
  return (
539
- "pNInz6obpgDQGcFmaJgB",
540
  VoiceSettings(
541
  stability=0.6,
542
  similarity_boost=0.8,
@@ -759,7 +759,7 @@ def mcp_agent_pipeline(
759
 
760
 
761
  # =============================================================================
762
- # GALLERY LOADING
763
  # =============================================================================
764
 
765
  def load_gallery_videos() -> List[str]:
@@ -771,26 +771,22 @@ def load_gallery_videos() -> List[str]:
771
  glob.glob(f"{gallery_output_dir}/*.mp4"),
772
  key=os.path.getmtime,
773
  reverse=True,
774
- )
 
 
 
 
775
 
776
- return existing_videos
777
 
778
 
779
  # =============================================================================
780
  # GRADIO UI
781
  # =============================================================================
782
 
783
- custom_css = """
784
- #video-gallery {
785
- max-height: 540px;
786
- overflow-y: auto;
787
- }
788
- """
789
-
790
  with gr.Blocks(
791
  title="AIQuoteClipGenerator - MCP + Gemini Edition",
792
  theme=gr.themes.Soft(),
793
- css=custom_css,
794
  ) as demo:
795
  gr.Markdown(
796
  """
@@ -802,17 +798,17 @@ with gr.Blocks(
802
  """
803
  )
804
 
805
- # Scrollable grid gallery
806
- with gr.Accordion("📸 Example Gallery – All Generated Videos", open=True):
807
- gr.Markdown("Scroll to explore all the clips you've generated so far.")
808
- gallery = gr.Gallery(
809
- label=None,
810
- show_label=False,
811
- elem_id="video-gallery",
812
- columns=3,
813
- height=540,
814
- preview=False,
815
- )
816
 
817
  gr.Markdown("---")
818
  gr.Markdown("## 🎯 Generate Your Own Quote Video")
@@ -923,8 +919,14 @@ with gr.Blocks(
923
  v3 = videos[2] if len(videos) > 2 else None
924
 
925
  gallery_vids = load_gallery_videos()
 
 
 
 
 
 
926
 
927
- return status, v1, v2, v3, gallery_vids
928
 
929
  generate_btn.click(
930
  process_and_display,
@@ -941,14 +943,33 @@ with gr.Blocks(
941
  video1,
942
  video2,
943
  video3,
944
- gallery,
 
 
 
 
 
945
  ],
946
  )
947
 
 
 
 
 
 
 
948
  demo.load(
949
- load_gallery_videos,
950
- outputs=[gallery],
 
 
 
 
 
 
 
951
  )
952
 
953
  if __name__ == "__main__":
954
- demo.launch(allowed_paths=["/data/gallery_videos"])
 
 
526
 
527
  if "rachel" in vp or "female" in vp:
528
  return (
529
+ "21m00Tcm4TlvDq8ikWAM", # Rachel
530
  VoiceSettings(
531
  stability=0.5,
532
  similarity_boost=0.9,
 
536
  )
537
 
538
  return (
539
+ "pNInz6obpgDQGcFmaJgB", # Adam
540
  VoiceSettings(
541
  stability=0.6,
542
  similarity_boost=0.8,
 
759
 
760
 
761
  # =============================================================================
762
+ # GALLERY (6 FIXED SLOTS)
763
  # =============================================================================
764
 
765
  def load_gallery_videos() -> List[str]:
 
771
  glob.glob(f"{gallery_output_dir}/*.mp4"),
772
  key=os.path.getmtime,
773
  reverse=True,
774
+ )[:6]
775
+
776
+ videos: List[str] = [None] * 6 # type: ignore
777
+ for i, path in enumerate(existing_videos):
778
+ videos[i] = path
779
 
780
+ return videos
781
 
782
 
783
  # =============================================================================
784
  # GRADIO UI
785
  # =============================================================================
786
 
 
 
 
 
 
 
 
787
  with gr.Blocks(
788
  title="AIQuoteClipGenerator - MCP + Gemini Edition",
789
  theme=gr.themes.Soft(),
 
790
  ) as demo:
791
  gr.Markdown(
792
  """
 
798
  """
799
  )
800
 
801
+ # 6-slot gallery grid (3x2)
802
+ with gr.Accordion("📸 Example Gallery – Recent Videos", open=True):
803
+ gr.Markdown("See what has been generated. Auto-updates after each run.")
804
+ with gr.Row():
805
+ gallery_video1 = gr.Video(height=300, show_label=False)
806
+ gallery_video2 = gr.Video(height=300, show_label=False)
807
+ gallery_video3 = gr.Video(height=300, show_label=False)
808
+ with gr.Row():
809
+ gallery_video4 = gr.Video(height=300, show_label=False)
810
+ gallery_video5 = gr.Video(height=300, show_label=False)
811
+ gallery_video6 = gr.Video(height=300, show_label=False)
812
 
813
  gr.Markdown("---")
814
  gr.Markdown("## 🎯 Generate Your Own Quote Video")
 
919
  v3 = videos[2] if len(videos) > 2 else None
920
 
921
  gallery_vids = load_gallery_videos()
922
+ g1 = gallery_vids[0] if len(gallery_vids) > 0 else None
923
+ g2 = gallery_vids[1] if len(gallery_vids) > 1 else None
924
+ g3 = gallery_vids[2] if len(gallery_vids) > 2 else None
925
+ g4 = gallery_vids[3] if len(gallery_vids) > 3 else None
926
+ g5 = gallery_vids[4] if len(gallery_vids) > 4 else None
927
+ g6 = gallery_vids[5] if len(gallery_vids) > 5 else None
928
 
929
+ return status, v1, v2, v3, g1, g2, g3, g4, g5, g6
930
 
931
  generate_btn.click(
932
  process_and_display,
 
943
  video1,
944
  video2,
945
  video3,
946
+ gallery_video1,
947
+ gallery_video2,
948
+ gallery_video3,
949
+ gallery_video4,
950
+ gallery_video5,
951
+ gallery_video6,
952
  ],
953
  )
954
 
955
+ # Load gallery when app starts
956
+ def initial_gallery():
957
+ vids = load_gallery_videos()
958
+ vids += [None] * (6 - len(vids))
959
+ return vids[:6]
960
+
961
  demo.load(
962
+ initial_gallery,
963
+ outputs=[
964
+ gallery_video1,
965
+ gallery_video2,
966
+ gallery_video3,
967
+ gallery_video4,
968
+ gallery_video5,
969
+ gallery_video6,
970
+ ],
971
  )
972
 
973
  if __name__ == "__main__":
974
+ demo.launch(allowed_paths=["/data/gallery_videos"])
975
+