File size: 2,979 Bytes
daf848e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import streamlit as st
import os
from crewai import Crew, Process
from agents import get_agents_and_tasks
from tools import send_mail

def generate_video(topic, openai_api_key, stabilityai_api_key, user_email):
    os.environ['OPENAI_API_KEY'] = openai_api_key
    grow_api_key = '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'
    if stabilityai_api_key is not None:
        os.environ['STABILITY_AI_API_KEY'] = stabilityai_api_key
        model = 'Stability AI'
    else:
        model = 'Dalle-2'
    agents, tasks = get_agents_and_tasks(grow_api_key)

    crew = Crew(
        agents=agents, 
        tasks=tasks,
        process=Process.sequential,
        memory=True,
        verbose=2
    )
    result = crew.kickoff(inputs={'topic': topic, 'model' : model})
    send_mail(user_email, result)
    return result

# Custom CSS for styling
st.markdown(
    """

    <style>

        .heading {

            font-size: 24px;

            font-weight: bold;

            text-align: center;

        }

        .subheading {

            font-size: 18px;

            font-weight: bold;

            text-align: center;

            margin-top: 10px;

        }

        .example-video-container {

            display: flex;

            flex-wrap: wrap;

            justify-content: flex-start;

        }

        .example-video {

            margin: 10px;

        }

    </style>

    """,
    unsafe_allow_html=True,
)

# Main content area
st.markdown(
    """

    <div class="heading">

        YouTube Shorts Creator

    </div>

    <div class="subheading">

        Generate stunning short videos with simple prompt

    </div>

    """,
    unsafe_allow_html=True,
)

# Space
st.text(" ")

# Main content for Input Details
st.markdown("## Input Details")
topic = st.text_input("Prompt")
openai_api_key = st.text_input("OpenAI API key")
size = st.selectbox('Size',
                    ('512 X 512', '1024 X 1024', '9:16'))
stabilityai_api_key = None
if size=='9:16':
    st.text_input('Stability Ai API key')
user_email = st.text_input("Email address", placeholder='[email protected]')

if st.button("Mail Me!"):
    st.text(f"Video will be sent to {user_email}")
    result = generate_video(topic, openai_api_key, stabilityai_api_key, user_email)
    #st.success(result)
    # In a real scenario, you would send the generated video to the user's email here

# Sidebar for Example Videos
st.sidebar.markdown("### Example Videos")
example_paths = os.listdir('results')
examples = [os.path.join('results', i) for i in example_paths]

# Display videos in a row
st.sidebar.markdown('<div class="example-video-container">', unsafe_allow_html=True)
for video_url in examples:
    title = video_url.split('\\')[1].split('.')[0]
    st.sidebar.text(f"input: {title}")
    st.sidebar.video(video_url, format="video/mp4", start_time=0)
st.sidebar.markdown("</div>", unsafe_allow_html=True)