Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,6 +69,11 @@ the_big_cat_story = [
|
|
69 |
{"text": "The cat is big. It jumps on the mat. The mat is soft. The cat takes a nap.", "image": f"{image_base_url}40.webp"}
|
70 |
]
|
71 |
|
|
|
|
|
|
|
|
|
|
|
72 |
# π gTTSλ₯Ό μ΄μ©ν΄ μ€λμ€ νμΌμ μμ±νκ±°λ, μ΄λ―Έ μμΌλ©΄ μ¬μ¬μ©
|
73 |
def generate_audio(text):
|
74 |
try:
|
@@ -138,6 +143,11 @@ the_big_cat_text = the_big_cat_story[0]["text"]
|
|
138 |
the_big_cat_image = the_big_cat_story[0]["image"]
|
139 |
the_big_cat_audio = generate_audio(the_big_cat_text)
|
140 |
|
|
|
|
|
|
|
|
|
|
|
141 |
# π Gradio UI ꡬμ±
|
142 |
with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
143 |
gr.HTML("""
|
@@ -335,6 +345,30 @@ with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
|
335 |
outputs=[audio_output_big_cat]
|
336 |
)
|
337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
|
339 |
# π μ± μ€ν
|
340 |
demo.launch()
|
|
|
69 |
{"text": "The cat is big. It jumps on the mat. The mat is soft. The cat takes a nap.", "image": f"{image_base_url}40.webp"}
|
70 |
]
|
71 |
|
72 |
+
# π "The Hot Sun" μ€ν 리 λ°μ΄ν°
|
73 |
+
the_hot_sun_story = [
|
74 |
+
{"text": "The sun is hot. I wear my hat. I drink some water. Now I feel cool!", "image": f"{image_base_url}41.webp"}
|
75 |
+
]
|
76 |
+
|
77 |
# π gTTSλ₯Ό μ΄μ©ν΄ μ€λμ€ νμΌμ μμ±νκ±°λ, μ΄λ―Έ μμΌλ©΄ μ¬μ¬μ©
|
78 |
def generate_audio(text):
|
79 |
try:
|
|
|
143 |
the_big_cat_image = the_big_cat_story[0]["image"]
|
144 |
the_big_cat_audio = generate_audio(the_big_cat_text)
|
145 |
|
146 |
+
the_hot_sun_index = 0
|
147 |
+
the_hot_sun_text = the_hot_sun_story[0]["text"]
|
148 |
+
the_hot_sun_image = the_hot_sun_story[0]["image"]
|
149 |
+
the_hot_sun_audio = generate_audio(the_hot_sun_text)
|
150 |
+
|
151 |
# π Gradio UI ꡬμ±
|
152 |
with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
153 |
gr.HTML("""
|
|
|
345 |
outputs=[audio_output_big_cat]
|
346 |
)
|
347 |
|
348 |
+
# -- The Hot Sun --
|
349 |
+
with gr.TabItem("The Hot Sun"):
|
350 |
+
state_index_hot_sun = gr.State(value=the_hot_sun_index)
|
351 |
+
state_text_hot_sun = gr.State(value=the_hot_sun_text)
|
352 |
+
|
353 |
+
story_text_hot_sun = gr.HTML(value=f"<div class='story-text'>{the_hot_sun_text}</div>")
|
354 |
+
story_image_hot_sun = gr.Image(value=the_hot_sun_image, width=300, height=300)
|
355 |
+
audio_output_hot_sun = gr.Audio(value=the_hot_sun_audio, autoplay=False)
|
356 |
+
|
357 |
+
with gr.Row():
|
358 |
+
next_button_hot_sun = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
359 |
+
play_button_hot_sun = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
360 |
+
|
361 |
+
next_button_hot_sun.click(
|
362 |
+
fn=next_story,
|
363 |
+
inputs=[state_index_hot_sun, gr.State(value=the_hot_sun_story)],
|
364 |
+
outputs=[state_index_hot_sun, story_text_hot_sun, story_image_hot_sun, audio_output_hot_sun, state_text_hot_sun]
|
365 |
+
)
|
366 |
+
|
367 |
+
play_button_hot_sun.click(
|
368 |
+
fn=play_story,
|
369 |
+
inputs=[state_text_hot_sun],
|
370 |
+
outputs=[audio_output_hot_sun]
|
371 |
+
)
|
372 |
|
373 |
# π μ± μ€ν
|
374 |
demo.launch()
|