Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from moviepy.editor import ImageClip, AudioFileClip | |
| from gtts import gTTS | |
| import os | |
| def create_video(arabic_text, input_image): | |
| # 1. توليد الصوت | |
| audio_path = "voice.mp3" | |
| tts = gTTS(text=arabic_text, lang='ar') | |
| tts.save(audio_path) | |
| # 2. تحميل الصوت والصورة | |
| audio = AudioFileClip(audio_path) | |
| # 3. إنشاء الفيديو مع تأثير الزووم الهادئ | |
| video_path = "final_output.mp4" | |
| clip = (ImageClip(input_image) | |
| .set_duration(audio.duration) | |
| .resize(lambda t: 1 + 0.05 * t) # زووم سينمائي | |
| .set_audio(audio)) | |
| # 4. حفظ الفيديو | |
| clip.write_videofile(video_path, fps=24, codec="libx264") | |
| return video_path | |
| # بناء واجهة الويب | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# 🎬 GenVid-Flow Studio") | |
| gr.Markdown("ارفع صورة واكتب النص اللي يوتيوب اقترحهولك.. والذكاء الاصطناعي هيحولهم لفيديو!") | |
| with gr.Row(): | |
| with gr.Column(): | |
| txt_input = gr.Textbox(label="النص العربي", placeholder="اكتب هنا...") | |
| img_input = gr.Image(label="ارفع صورة المشهد", type="filepath") | |
| btn = gr.Button("🚀 ابدأ صناعة الفيديو", variant="primary") | |
| with gr.Column(): | |
| video_output = gr.Video(label="الفيديو الناتج") | |
| btn.click(fn=create_video, inputs=[txt_input, img_input], outputs=video_output) | |
| demo.launch() |