File size: 1,614 Bytes
a15c324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()