Manasa1 commited on
Commit
58a7ec6
·
verified ·
1 Parent(s): 5a834fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -1
app.py CHANGED
@@ -82,7 +82,53 @@ def generate_kids_animation_with_music(theme, output_video_file="kids_animation.
82
  img = Image.new('RGB', (800, 400), color=(0, 0, 255))
83
  d = ImageDraw.Draw(img)
84
  fnt = ImageFont.load_default()
85
- d.text((10, 180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
 
88
 
 
82
  img = Image.new('RGB', (800, 400), color=(0, 0, 255))
83
  d = ImageDraw.Draw(img)
84
  fnt = ImageFont.load_default()
85
+ d.text((10, 180), f"Kids Music: {theme}", font=fnt, fill=(255, 255, 0))
86
+ frame_path = f'/tmp/kids_temp_{i}.png'
87
+ img.save(frame_path)
88
+ clips.append(ImageClip(frame_path).set_duration(1).set_position(('center', 'center')))
89
+ final_video = CompositeVideoClip(clips, size=(800, 400))
90
+ final_video = final_video.set_audio(AudioFileClip(music_file))
91
+ final_video.write_videofile(output_video_file, fps=24)
92
+ return music_file, output_video_file
93
+
94
+ # Main Function to Generate Kids Content
95
+ def generate_kids_content(theme):
96
+ music_file, video_file = generate_kids_animation_with_music(theme)
97
+ return music_file, video_file
98
+
99
+ # Gradio Interface
100
+ with gr.Blocks() as app:
101
+ gr.Markdown("## AI Comedy and Kids Content Generator")
102
+
103
+ # Comedy Animation Tab
104
+ with gr.Tab("Generate Comedy Animation"):
105
+ prompt_input = gr.Textbox(label="Comedy Prompt")
106
+ generate_btn = gr.Button("Generate Comedy Script and Animation")
107
+ comedy_script = gr.Textbox(label="Generated Script")
108
+ comedy_audio = gr.Audio(label="Generated Audio")
109
+ comedy_video = gr.Video(label="Generated Animation")
110
+
111
+ generate_btn.click(
112
+ generate_comedy_and_animation,
113
+ inputs=prompt_input,
114
+ outputs=[comedy_script, comedy_audio, comedy_video]
115
+ )
116
+
117
+ # Kids Music Animation Tab
118
+ with gr.Tab("Generate Kids Music Animation"):
119
+ theme_input = gr.Textbox(label="Kids Music Theme")
120
+ generate_music_btn = gr.Button("Generate Kids Music and Animation")
121
+ kids_music_audio = gr.Audio(label="Generated Music")
122
+ kids_music_video = gr.Video(label="Generated Kids Animation")
123
+
124
+ generate_music_btn.click(
125
+ generate_kids_content,
126
+ inputs=theme_input,
127
+ outputs=[kids_music_audio, kids_music_video]
128
+ )
129
+
130
+ app.launch()
131
+
132
 
133
 
134