englissi commited on
Commit
091700c
Β·
verified Β·
1 Parent(s): 29e8a88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
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()