gradio edge-tts moviepy==1.0.3 import gradio as gr import edge_tts import asyncio from moviepy.editor import AudioFileClip, ColorClip import os # دالة توليد الصوت (تعمل في الخلفية بقوة السيرفر) async def generate_audio(text, voice): audio_path = "temp_audio.mp3" communicate = edge_tts.Communicate(text, voice) await communicate.save(audio_path) return audio_path # دالة المونتاج وتوليد الفيديو def generate_video(text): if not text.strip(): return None, "الرجاء إدخال فكرة الفيديو!" try: # 1. توليد الصوت voice_choice = "ar-EG-SalmaNeural" # صوت عربي audio_path = asyncio.run(generate_audio(text, voice_choice)) # 2. المونتاج (صنع الفيديو) audio_clip = AudioFileClip(audio_path) # إنشاء خلفية فيديو زرقاء كبداية (في المستقبل سنربطها بصور حقيقية) video_clip = ColorClip(size=(1080, 1920), color=(15, 32, 39), duration=audio_clip.duration) final_clip = video_clip.set_audio(audio_clip) video_path = "output_video.mp4" final_clip.write_videofile(video_path, fps=24, codec="libx264", audio_codec="aac") return video_path, "✅ تم توليد الفيديو بنجاح بقوة السيرفر السحابي!" except Exception as e: return None, f"حدث خطأ: {str(e)}" # تصميم واجهة الموقع with gr.Blocks(theme=gr.themes.Monochrome()) as demo: gr.Markdown("

🚀 AI Master Video Studio

") gr.Markdown("

مولد الفيديوهات الذكي - أقوى من MoneyPrinterTurbo

") with gr.Row(): with gr.Column(): text_input = gr.Textbox(label="اكتب النص الذي تريد تحويله لفيديو (عربي):", lines=4, placeholder="مرحباً بكم في قناتنا، اليوم سنتحدث عن...") generate_btn = gr.Button("🎬 اصنع الفيديو الآن", variant="primary") status_text = gr.Textbox(label="حالة النظام:", interactive=False) with gr.Column(): video_output = gr.Video(label="الفيديو النهائي (جاهز للتحميل)") # ربط الزر بالمحرك generate_btn.click(fn=generate_video, inputs=[text_input], outputs=[video_output, status_text]) # تشغيل الموقع if __name__ == "__main__": demo.launch()