Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,32 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from moviepy.editor import *
|
| 3 |
-
from TTS.api import TTS
|
| 4 |
import tempfile, os
|
|
|
|
| 5 |
|
| 6 |
-
st.title("
|
| 7 |
|
| 8 |
@st.cache_resource()
|
| 9 |
-
def
|
| 10 |
-
return
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
input_text = st.text_area("Enter
|
| 15 |
|
| 16 |
-
if st.button("Generate
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
final_clip.write_videofile(final_video_path, fps=5)
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
os.remove(final_video_path)
|
| 34 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from moviepy.editor import *
|
|
|
|
| 3 |
import tempfile, os
|
| 4 |
+
from transformers import pipeline
|
| 5 |
|
| 6 |
+
st.title("Simplified Text-to-Video (no TTS temporarily)")
|
| 7 |
|
| 8 |
@st.cache_resource()
|
| 9 |
+
def load_model():
|
| 10 |
+
return pipeline('text-to-video-generation', model='cerspense/zeroscope_v2_XS')
|
| 11 |
|
| 12 |
+
video_gen = load_model()
|
| 13 |
|
| 14 |
+
input_text = st.text_area("Enter short text (max 50 chars):", max_chars=50)
|
| 15 |
|
| 16 |
+
if st.button("Generate Video"):
|
| 17 |
+
if input_text:
|
| 18 |
+
with st.spinner("Generating video..."):
|
| 19 |
+
video_output = video_gen(input_text, num_frames=10)
|
| 20 |
+
video_tensor = video_output["video"]
|
| 21 |
+
video_np = (video_tensor * 255).astype('uint8')
|
| 22 |
|
| 23 |
+
video_filename = tempfile.mktemp(".mp4")
|
| 24 |
+
clips = [ImageClip(frame).set_duration(0.3) for frame in video_np]
|
| 25 |
+
final_clip = concatenate_videoclips(clips, method="compose")
|
| 26 |
+
final_clip.write_videofile(video_filename, fps=5)
|
| 27 |
|
| 28 |
+
st.video(video_filename)
|
|
|
|
| 29 |
|
| 30 |
+
os.remove(video_filename)
|
| 31 |
+
else:
|
| 32 |
+
st.warning("Please enter text.")
|
|
|
|
|
|