ZeeAI1 commited on
Commit
fe80cd3
·
verified ·
1 Parent(s): a611c8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -22
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("Simple Text-to-Video App")
7
 
8
  @st.cache_resource()
9
- def load_tts():
10
- return TTS("tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False)
11
 
12
- tts_model = load_tts()
13
 
14
- input_text = st.text_area("Enter very short text (max 100 chars):", max_chars=100)
15
 
16
- if st.button("Generate Simple Video") and input_text:
17
- with st.spinner("Generating..."):
18
- # Audio Only (no cloning, fast)
19
- audio_filename = tempfile.mktemp(".wav")
20
- tts_model.tts_to_file(text=input_text, file_path=audio_filename)
 
21
 
22
- # Single static image as video (for demonstration)
23
- img_clip = ColorClip(size=(320, 240), color=(0, 0, 255)).set_duration(5)
24
- audio_clip = AudioFileClip(audio_filename)
25
- final_clip = img_clip.set_audio(audio_clip)
26
 
27
- final_video_path = tempfile.mktemp(".mp4")
28
- final_clip.write_videofile(final_video_path, fps=5)
29
 
30
- st.video(final_video_path)
31
-
32
- os.remove(audio_filename)
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.")