englissi commited on
Commit
a4ad2c0
Β·
verified Β·
1 Parent(s): 367abd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -9
app.py CHANGED
@@ -30,7 +30,14 @@ def generate_audio(text, filename="story.mp3"):
30
  # μŠ€ν† λ¦¬ ν…μŠ€νŠΈλ₯Ό HTML μŠ€νƒ€μΌλ‘œ 크게 ν‘œμ‹œν•˜κ³  쀑앙 μ •λ ¬ν•˜λŠ” ν•¨μˆ˜
31
  def format_story_text(text):
32
  return f"""
33
- <div style='font-size:4em; font-weight:bold; text-align:center; margin: 20px 0;'>
 
 
 
 
 
 
 
34
  {text}
35
  </div>
36
  """
@@ -62,11 +69,15 @@ def play_story(current_text):
62
  init_index, init_text, init_image, init_audio = init_story()
63
 
64
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
65
- with gr.Blocks(title="μŠ€ν† λ¦¬ μ•±") as demo:
66
- gr.Markdown("## πŸ“– μŠ€ν† λ¦¬ μ•±", elem_id="title", style="text-align:center;")
67
  gr.Markdown(
68
- "<div style='text-align:center;'>μ•„λž˜μ˜ μŠ€ν† λ¦¬λ₯Ό ν™•μΈν•˜μ„Έμš”. <br> **λ‹€μŒ** λ²„νŠΌμ„ 눌러 μŠ€ν† λ¦¬λ₯Ό μˆœμ„œλŒ€λ‘œ λ³Ό 수 있으며, μŒμ„±μ΄ μžλ™ μž¬μƒλ©λ‹ˆλ‹€. "
69
- "<br> μŒμ„±μ„ λ‹€μ‹œ λ“£κ³  μ‹ΆμœΌλ©΄ **μž¬μƒ** λ²„νŠΌμ„ λˆŒλŸ¬μ£Όμ„Έμš”.</div>",
 
 
 
 
 
70
  unsafe_allow_html=True
71
  )
72
 
@@ -76,12 +87,17 @@ with gr.Blocks(title="μŠ€ν† λ¦¬ μ•±") as demo:
76
 
77
  # UI μ»΄ν¬λ„ŒνŠΈ 생성
78
  story_text = gr.Markdown(value=format_story_text(init_text), label="μŠ€ν† λ¦¬")
79
- story_image = gr.Image(value=init_image, label="이미지", type="filepath", width=400, height=400)
80
- audio_output = gr.Audio(value=init_audio, label="μŒμ„± μž¬μƒ", type="filepath", autoplay=True)
 
 
 
 
 
81
 
82
  with gr.Row():
83
- next_button = gr.Button("λ‹€μŒ")
84
- play_button = gr.Button("μž¬μƒ")
85
 
86
  # "λ‹€μŒ" λ²„νŠΌ 클릭 이벀트 처리
87
  next_button.click(
@@ -97,5 +113,33 @@ with gr.Blocks(title="μŠ€ν† λ¦¬ μ•±") as demo:
97
  outputs=[audio_output]
98
  )
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  # μ•± μ‹€ν–‰
101
  demo.launch()
 
30
  # μŠ€ν† λ¦¬ ν…μŠ€νŠΈλ₯Ό HTML μŠ€νƒ€μΌλ‘œ 크게 ν‘œμ‹œν•˜κ³  쀑앙 μ •λ ¬ν•˜λŠ” ν•¨μˆ˜
31
  def format_story_text(text):
32
  return f"""
33
+ <div style='
34
+ font-size:4em;
35
+ font-weight:bold;
36
+ text-align:center;
37
+ color:#FF4500;
38
+ font-family:sans-serif;
39
+ margin: 20px 0;
40
+ '>
41
  {text}
42
  </div>
43
  """
 
69
  init_index, init_text, init_image, init_audio = init_story()
70
 
71
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
72
+ with gr.Blocks(title="πŸ“š κ·€μ—¬μš΄ μŠ€ν† λ¦¬ μ•±") as demo:
 
73
  gr.Markdown(
74
+ "<div style='text-align:center; font-size:2em; font-weight:bold;'>🎈 μž¬λ―ΈμžˆλŠ” μ˜μ–΄ μŠ€ν† λ¦¬ νƒ€μž„! πŸ“–</div>",
75
+ unsafe_allow_html=True
76
+ )
77
+
78
+ gr.Markdown(
79
+ "<div style='text-align:center; font-size:1.2em;'>🐱 κ·€μ—¬μš΄ 이야기와 ν•¨κ»˜ μ˜μ–΄λ₯Ό λ°°μ›Œλ³΄μ•„μš”! <br> "
80
+ "λ²„νŠΌμ„ 눌러 λ‹€μŒ μ΄μ•ΌκΈ°λ‘œ λ„˜μ–΄κ°€κ³ , μŒμ„±μ„ λ“€μœΌλ©° 따라 μ½μ–΄λ³΄μ„Έμš”! 🎡</div>",
81
  unsafe_allow_html=True
82
  )
83
 
 
87
 
88
  # UI μ»΄ν¬λ„ŒνŠΈ 생성
89
  story_text = gr.Markdown(value=format_story_text(init_text), label="μŠ€ν† λ¦¬")
90
+
91
+ story_image = gr.Image(
92
+ value=init_image, label="이미지", type="filepath", width=400, height=400,
93
+ container=True
94
+ )
95
+
96
+ audio_output = gr.Audio(value=init_audio, label="🎧 μŒμ„± μž¬μƒ", type="filepath", autoplay=True)
97
 
98
  with gr.Row():
99
+ next_button = gr.Button("πŸ‘‰ λ‹€μŒ 이야기", elem_id="next-btn")
100
+ play_button = gr.Button("πŸ”Š λ‹€μ‹œ λ“£κΈ°", elem_id="play-btn")
101
 
102
  # "λ‹€μŒ" λ²„νŠΌ 클릭 이벀트 처리
103
  next_button.click(
 
113
  outputs=[audio_output]
114
  )
115
 
116
+ # CSS μŠ€νƒ€μΌ μΆ”κ°€ (κ·€μ—¬μš΄ ν…Œλ§ˆ)
117
+ demo.css = """
118
+ body {
119
+ background-color: #FFFAF0; /* λ”°λœ»ν•œ 크림색 λ°°κ²½ */
120
+ }
121
+
122
+ #next-btn {
123
+ background-color: #FFD700; /* λ…Έλž€μƒ‰ λ²„νŠΌ */
124
+ font-size: 1.5em;
125
+ font-weight: bold;
126
+ border-radius: 20px;
127
+ padding: 10px;
128
+ }
129
+
130
+ #play-btn {
131
+ background-color: #90EE90; /* μ—°ν•œ μ΄ˆλ‘μƒ‰ λ²„νŠΌ */
132
+ font-size: 1.5em;
133
+ font-weight: bold;
134
+ border-radius: 20px;
135
+ padding: 10px;
136
+ }
137
+
138
+ img {
139
+ border-radius: 10px; /* λ‘₯κ·Ό ν…Œλ‘λ¦¬ */
140
+ border: 5px solid #FFFFFF; /* 흰색 ν…Œλ‘λ¦¬ */
141
+ }
142
+ """
143
+
144
  # μ•± μ‹€ν–‰
145
  demo.launch()