File size: 3,261 Bytes
f636163
 
 
 
 
 
 
 
b0cf40a
f636163
 
b0cf40a
8e4df09
f636163
 
 
 
8e4df09
f636163
 
 
 
b0cf40a
f636163
 
8844063
 
f636163
8e4df09
 
 
 
 
 
 
 
 
fb1fb29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1833f3c
fb1fb29
 
 
8e4df09
 
 
 
 
 
 
 
 
 
b0cf40a
8e4df09
ab79aee
 
5f290c1
 
 
 
ef2cf91
 
8e4df09
 
 
 
b0cf40a
f636163
a87aeaf
068543b
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
102
103
import gradio as gr
import os

from crewai import Crew, Process
# from agents import *
from agents import get_agents_and_tasks


def generate_video(topic, stability_ai_api_key):#, openai_api_key):
    # os.environ['GROQ_API_KEY'] = grow_api_key
    os.environ['STABILITY_AI_API_KEY'] = stability_ai_api_key
    # os.environ['OPENAI_API_KEY'] = openai_api_key
    grow_api_key = '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'
    agents, tasks = get_agents_and_tasks(grow_api_key)

    crew = Crew(
    # agents=[script_agent, image_descriptive_agent, img_speech_generating_agent, editor],
    # tasks=[content_generation_task, story_writing_task, img_text_task, img_generation_task,speech_generation_task,make_video_task],
    agents = agents, 
    tasks = tasks,
    process = Process.sequential,
    # cache = True,
    # memory=True,
    verbose=2
    )
    result = crew.kickoff(inputs={'topic': topic})
    return result

# app = gr.Interface(
#     fn=generate_video,
#     inputs=['text', 'text'],
#     # outputs=gr.Video(value=os.path.join('outputs/final_video/video.mp4'),label="Generated Video", width=720/2, height=1280/2),
#     outputs = gr.Video(format='mp4',label="Generated Video", width=720/2, height=1280/2),
#     title="ShortsIn",
#     description="Shorts generator"
# )
intro = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Shorts Generator Page</title>
    <style>
        .heading {
            font-size: 24px;
            font-weight: bold;
            text-align: center;
        }
        .subheading {
            font-size: 18px;
            font-weight: bold;
            text-align: center;
            margin-top: 10px;
        }
        .additional-text {
            font-size: 16px;
            text-align: center;
            margin-top: 20px;
            white-space: pre-line; /* Preserve line breaks */
        }
    </style>
</head>
<body>
    <div class="heading">
        ShortsIn
    </div>
    <div class="subheading">
        YouTube shorts generator
    </div>
    <div class="additional-text">
        Note: One API key can generate two videos. Stability ai provides free credits. Visit <a href="https://platform.stability.ai/account/keys" target="_blank">Stability AI</a> for your API key.
    </div>
</body>
</html>
"""

with gr.Blocks(title='ShortsIn') as app:

  gr.HTML(intro)

  with gr.Row():
    with gr.Column():
      inp = gr.Textbox(label='Enter title here')
      api = gr.Textbox(label='Enter Stibility ai API key here')
      # api1 = gr.Textbox(label='Enter your openai API key here')
      btn = gr.Button('Generate', size='lg')
      text = gr.Textbox(label = 'Stability ai API Keys for judges', 
                        value = """
    1. sk-YZD8hJKTDfBgb7ny3QtbYnjgZTNtMDuxDqUDrgAn5gCqrtC6
    2. sk-9zFQSOC3ZiKxRqufH9ZTZM1foCiwOeiPVrYvgUfQBMuW96UL
    3. sk-TbVHSb5v1QVFwUyR4OA8yu7yvhSGXjkcrZcBDdJh60MhqB3n
    
    Incase of error, use different API key
    """)
    with gr.Column():
      out = gr.Video(label='', height=720, width=405)
      

  btn.click(fn=generate_video, inputs=[inp, api], outputs=out)

app.launch()
#os.path.dirname(os.path.abspath(__file__))