Download app.py from hhh454/22: direct link, hf CLI and curl.
- Browser
- Download file 842 Bytes
-
https://huggingface.co/spaces/hhh454/22/resolve/main/app.py
- Command line
-
hf download hf://spaces/hhh454/22/app.py
-
curl -L -o app.py https://huggingface.co/spaces/hhh454/22/resolve/main/app.py
842 Bytes
| import gradio as gr | |
| from gtts import gTTS | |
| from moviepy.editor import * | |
| from PIL import Image | |
| import requests | |
| def generate_video(text): | |
| # تحميل صورة مباشرة | |
| img_url = "https://picsum.photos/1280/720" | |
| img_data = requests.get(img_url).content | |
| with open("image.jpg", "wb") as f: | |
| f.write(img_data) | |
| # توليد صوت | |
| tts = gTTS(text) | |
| tts.save("voice.mp3") | |
| # إنشاء الفيديو | |
| image = ImageClip("image.jpg").set_duration(10) | |
| audio = AudioFileClip("voice.mp3") | |
| video = image.set_audio(audio) | |
| video.write_videofile("output.mp4", fps=24) | |
| return "output.mp4" | |
| demo = gr.Interface( | |
| fn=generate_video, | |
| inputs=gr.Textbox(label="اكتب الفكرة هنا"), | |
| outputs=gr.Video(label="الفيديو"), | |
| title="AI Video Generator 🔥" | |
| ) | |
| demo.launch() |