Spaces:
Running
Running
import streamlit as st | |
from gradio_client import Client | |
from utils import get_scenes, generate_video_assets, generate_video # Import the function from utils.py | |
# Title | |
st.markdown( | |
"<h1 style='text-align: center;'>Text to Video Generator</h1>", | |
unsafe_allow_html=True | |
) | |
st.markdown("<p style='text-align: center;'>Leave a Like if it works for you! ❤️</p>", unsafe_allow_html=True) | |
# Text input box with a max of 1500 characters | |
text_script = st.text_area("Enter your script/story (max 1500 characters):", max_chars=1500) | |
# Initialize the client with the hosted model | |
client = Client("habib926653/Multilingual-TTS") | |
# Dropdown for language selection | |
language = st.selectbox("Choose Language:", ["Urdu", "English"]) # Add more languages as needed | |
# Get available speakers for the selected language | |
speakers_response = client.predict(language=language, api_name="/get_speakers") | |
# Extract speakers list | |
speakers = [choice[0] for choice in speakers_response["choices"]] | |
selected_speaker = st.selectbox("Choose Speaker:", speakers) | |
# Button to trigger the processing | |
if st.button("Generate Video"): | |
if text_script: | |
# Call the function from utils.py to process the text | |
scenes = get_scenes(text_script) | |
video_assets_folder = generate_video_assets(scenes, language, selected_speaker) | |
generated_video_path = generate_video(video_assets_folder) | |
st.video(generated_video_path) | |
else: | |
st.warning("Please enter some text to generate prompts.") | |
st.markdown("### 🔥 See How It Works (Example)") | |
# Example video (Replace 'crow_example.mp4' with your actual file path or URL) | |
example_video_path = "crow_example.mp4" # Change to your actual video file | |
st.video(example_video_path) | |
# Example script in an expandable section | |
with st.expander("📜 View Example Script"): | |
st.markdown(""" | |
**Title:** Thirsty Crow (yep, the simplest example I came up with) | |
**Script:** | |
One hot summer day, a thirsty crow was flying in search of water. He looked everywhere, but he couldn't find a single drop. Tired and exhausted, he finally spotted a clay pot with a little water at the bottom. | |
The crow tried to reach the water, but his beak couldn’t go deep enough. He thought hard and came up with a clever idea. He picked up small pebbles one by one and dropped them into the pot. With each pebble, the water level slowly rose higher and higher. | |
Finally, after many pebbles, the water reached the top. The crow happily drank the water and flew away, refreshed and satisfied | |
""") | |