AbuAlone09 commited on
Commit
acc2571
Β·
verified Β·
1 Parent(s): 30aa2b8

Update webui/run_app.py

Browse files
Files changed (1) hide show
  1. webui/run_app.py +94 -1
webui/run_app.py CHANGED
@@ -76,4 +76,97 @@ def handle_rendering(video_script, clip_duration, voice_rate, selected_voice, en
76
  voice_name=selected_voice,
77
  voice_rate=voice_rate,
78
  subtitle_enabled=enable_subtitles,
79
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  voice_name=selected_voice,
77
  voice_rate=voice_rate,
78
  subtitle_enabled=enable_subtitles,
79
+ bgm_type="random" if enable_bgm else "",
80
+ n_threads=2
81
+ )
82
+
83
+ try:
84
+ # Step 1: Initialization
85
+ yield None, stream_log("Initializing AI Video Pipeline...")
86
+ if is_vip:
87
+ yield None, stream_log("VIP/Admin Key verified. Priority granted.", "SUCCESS")
88
+
89
+ # Step 2: Asset Discovery
90
+ yield None, stream_log(f"Searching high-quality clips for: '{params.video_subject}'")
91
+ yield None, stream_log("Requesting portrait orientation from Pexels API...")
92
+
93
+ # START ENGINE
94
+ # The engine logic is strictly preserved
95
+ result = tm.start(task_id=task_id, params=params)
96
+
97
+ # Step 3: Synthesis & Post-Processing
98
+ # Update logs immediately after core task processing
99
+ yield None, stream_log("Downloading video assets to local cache...")
100
+ yield None, stream_log("Synthesizing AI Voiceover and aligning subtitles...")
101
+ yield None, stream_log("FFmpeg: Merging visual elements with background music...")
102
+
103
+ if result and "videos" in result and len(result["videos"]) > 0:
104
+ video_path = result["videos"][0]
105
+ yield None, stream_log("Post-processing completed. Finalizing file...")
106
+ yield video_path, stream_log("SUCCESS: Video generated successfully!", "SUCCESS")
107
+ else:
108
+ yield None, stream_log("ERROR: Engine returned empty output.", "FAILED")
109
+
110
+ except Exception as e:
111
+ logger.error(f"Execution Error: {str(e)}")
112
+ yield None, stream_log(f"CRITICAL ERROR: {str(e)}", "ERROR")
113
+
114
+ # --- 4. GRADIO UI (PURE ENGLISH) ---
115
+ with gr.Blocks(theme=gr.Theme.from_hub("NeoPy/shadowthedgehog"), css=CSS) as demo:
116
+ gr.HTML('<div class="main-title">AI VIDEO ENGINE PRO</div>')
117
+
118
+ with gr.Row():
119
+ # Configuration Column
120
+ with gr.Column(scale=1):
121
+ with gr.Group():
122
+ gr.Markdown("### βš™οΈ Video Configuration")
123
+ v_key = gr.Textbox(label="πŸ”‘ VIP ACCESS", placeholder="Enter VIP Key...", type="password", elem_classes="vip-input")
124
+ v_script = gr.Textbox(label="VIDEO SCRIPT", placeholder="Enter your story script here...", lines=8, max_length=1500)
125
+
126
+ with gr.Row():
127
+ v_duration = gr.Slider(5, 10, value=5, step=1, label="Clip Length (s)")
128
+ v_rate = gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Voice Speed")
129
+
130
+ v_voice = gr.Dropdown(get_voice_list(), value="vi-VN-HoaiMyNeural", label="TTS Voice Artist")
131
+
132
+ with gr.Row():
133
+ v_sub = gr.Checkbox(label="Enable Subtitles", value=True)
134
+ v_bgm = gr.Checkbox(label="Enable BGM", value=True)
135
+
136
+ gen_btn = gr.Button("πŸš€ GENERATE VIDEO", variant="primary", elem_classes="gen-btn")
137
+
138
+ with gr.Group():
139
+ gr.Markdown("### πŸ“Ÿ REAL-TIME ENGINE LOGS")
140
+ # Lines=8 and autoscroll via CSS
141
+ console_output = gr.Textbox(label=None, lines=8, elem_classes="console-log", interactive=False, autoscroll=True)
142
+
143
+ # Output Column
144
+ with gr.Column(scale=1):
145
+ gr.Markdown("### 🎬 RESULT PREVIEW")
146
+ video_output = gr.Video(label="Generated Video", interactive=False, show_label=False)
147
+
148
+ with gr.Group():
149
+ gr.Markdown("### πŸ“Š System Status")
150
+ gr.Markdown("Environment: **ZeroGPU Cloud**\nEngine Version: **2.5.5 Stable**")
151
+
152
+ gr.Markdown("> **Notice:** The video player will automatically load once the engine finishes the FFmpeg merge process.")
153
+
154
+ gr.HTML(f"""
155
+ <div class="footer-container">
156
+ <hr>
157
+ Β© Source 2024 Harry | Development 2026 Abu Alone<br>
158
+ <b>Reproduction strictly prohibited</b>
159
+ </div>
160
+ """)
161
+
162
+ # --- 5. EVENTS ---
163
+ gen_btn.click(
164
+ fn=handle_rendering,
165
+ inputs=[v_script, v_duration, v_rate, v_voice, v_sub, v_bgm, v_key],
166
+ outputs=[video_output, console_output]
167
+ )
168
+
169
+ if __name__ == "__main__":
170
+ # Max_size=2 to prevent GPU overload while maintaining queue
171
+ demo.queue(max_size=2).launch(server_name="0.0.0.0", server_port=7860)
172
+