Prudvireddy commited on
Commit
8e4df09
1 Parent(s): b951a7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -11
app.py CHANGED
@@ -6,15 +6,16 @@ from crewai import Crew, Process
6
  from agents import get_agents_and_tasks
7
 
8
 
9
- def generate_video(topic, grow_api_key, stability_ai_api_key,openai_api_key):
10
  # os.environ['GROQ_API_KEY'] = grow_api_key
11
  os.environ['STABILITY_AI_API_KEY'] = stability_ai_api_key
12
- os.environ['OPENAI_API_KEY'] = openai_api_key
 
13
  agents, tasks = get_agents_and_tasks(grow_api_key)
14
 
15
  crew = Crew(
16
  # agents=[script_agent, image_descriptive_agent, img_speech_generating_agent, editor],
17
- # tasks=[content_generation_task, story_writing_task, img_text_task,speech_generation_task,make_video_task],
18
  agents = agents,
19
  tasks = tasks,
20
  process = Process.sequential,
@@ -25,14 +26,39 @@ def generate_video(topic, grow_api_key, stability_ai_api_key,openai_api_key):
25
  crew.kickoff(inputs={'topic': topic})
26
  return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'outputs/final_video/final_video.mp4')
27
 
28
- app = gr.Interface(
29
- fn=generate_video,
30
- inputs=['text', 'text', 'text', 'text'],
31
- # outputs=gr.Video(value=os.path.join('outputs/final_video/video.mp4'),label="Generated Video", width=720/2, height=1280/2),
32
- outputs = gr.Video(format='mp4',label="Generated Video", width=720/2, height=1280/2),
33
- title="ShortsIn",
34
- description="Shorts generator"
35
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  app.launch()
38
  #os.path.dirname(os.path.abspath(__file__))
 
6
  from agents import get_agents_and_tasks
7
 
8
 
9
+ def generate_video(topic, stability_ai_api_key):
10
  # os.environ['GROQ_API_KEY'] = grow_api_key
11
  os.environ['STABILITY_AI_API_KEY'] = stability_ai_api_key
12
+ os.environ['OPENAI_API_KEY'] = 'sk-proj-0zw99wkFRW5V3tc6xZONT3BlbkFJqNbENviPvW4T3YyiktGL'
13
+ grow_api_key = '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'
14
  agents, tasks = get_agents_and_tasks(grow_api_key)
15
 
16
  crew = Crew(
17
  # agents=[script_agent, image_descriptive_agent, img_speech_generating_agent, editor],
18
+ # tasks=[content_generation_task, story_writing_task, img_text_task, img_generation_task,speech_generation_task,make_video_task],
19
  agents = agents,
20
  tasks = tasks,
21
  process = Process.sequential,
 
26
  crew.kickoff(inputs={'topic': topic})
27
  return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'outputs/final_video/final_video.mp4')
28
 
29
+ # app = gr.Interface(
30
+ # fn=generate_video,
31
+ # inputs=['text', 'text'],
32
+ # # outputs=gr.Video(value=os.path.join('outputs/final_video/video.mp4'),label="Generated Video", width=720/2, height=1280/2),
33
+ # outputs = gr.Video(format='mp4',label="Generated Video", width=720/2, height=1280/2),
34
+ # title="ShortsIn",
35
+ # description="Shorts generator"
36
+ # )
37
+ intro = """
38
+ <div style="text-align:center">
39
+ <h1 style="font-weight: 1700; text-align: center; margin-bottom: 7px;">
40
+ ShortsIn
41
+ </h1>
42
+ <div style="display:flex; justify-content: center;margin-top: 0.5em; color: white;">
43
+ convert text to Youtube Shorts
44
+ </div>
45
+ </div>
46
+ """
47
+
48
+ with gr.Blocks(title='ShortsIn') as app:
49
+
50
+ gr.HTML(intro)
51
+
52
+ with gr.Row():
53
+ with gr.Column():
54
+ inp = gr.Textbox(label='Enter title here')
55
+ api = gr.Textbox(label='Enter Stibility ai API key here')
56
+ btn = gr.Button('Generate', size='lg')
57
+ with gr.Column():
58
+ out = gr.Video(label='', height=720, width=405)
59
+
60
+
61
+ btn.click(fn=generate_video, inputs=[inp, api], outputs=out)
62
 
63
  app.launch()
64
  #os.path.dirname(os.path.abspath(__file__))