Manasa1 commited on
Commit
629b60b
·
verified ·
1 Parent(s): a9da28b

Update app.py

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