Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import subprocess | |
| import os | |
| def generate_video(image, audio): | |
| if image is None or audio is None: | |
| return None, "❌ لازم صورة وصوت" | |
| os.makedirs("outputs", exist_ok=True) | |
| output_path = "outputs/result.mp4" | |
| # ⚠️ هذا يفترض أنك ركبت SadTalker أو Wav2Lip داخل Space | |
| cmd = f"python inference.py --face {image} --audio {audio} --outfile {output_path}" | |
| try: | |
| subprocess.run(cmd, shell=True, check=True) | |
| return output_path, "🎬 Video generated successfully!" | |
| except Exception as e: | |
| return None, f"❌ Error: {str(e)}" | |
| with gr.Blocks() as app: | |
| gr.Markdown("# 🎬 AI Avatar Video Generator") | |
| with gr.Row(): | |
| image_input = gr.Image(type="filepath", label="📸 Image") | |
| audio_input = gr.Audio(type="filepath", label="🎤 Audio") | |
| btn = gr.Button("🚀 Generate Video") | |
| video_output = gr.Video(label="🎥 Output Video") | |
| status = gr.Textbox(label="Status") | |
| btn.click( | |
| fn=generate_video, | |
| inputs=[image_input, audio_input], | |
| outputs=[video_output, status] | |
| ) | |
| app.launch() |