Spaces:
Running
Running
import streamlit as st | |
from moviepy.editor import * | |
from TTS.api import TTS | |
import tempfile, os | |
st.title("Simple Text-to-Video App") | |
def load_tts(): | |
return TTS("tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False) | |
tts_model = load_tts() | |
input_text = st.text_area("Enter very short text (max 100 chars):", max_chars=100) | |
if st.button("Generate Simple Video") and input_text: | |
with st.spinner("Generating..."): | |
# Audio Only (no cloning, fast) | |
audio_filename = tempfile.mktemp(".wav") | |
tts_model.tts_to_file(text=input_text, file_path=audio_filename) | |
# Single static image as video (for demonstration) | |
img_clip = ColorClip(size=(320, 240), color=(0, 0, 255)).set_duration(5) | |
audio_clip = AudioFileClip(audio_filename) | |
final_clip = img_clip.set_audio(audio_clip) | |
final_video_path = tempfile.mktemp(".mp4") | |
final_clip.write_videofile(final_video_path, fps=5) | |
st.video(final_video_path) | |
os.remove(audio_filename) | |
os.remove(final_video_path) | |