openfree commited on
Commit
e49bf8d
ยท
verified ยท
1 Parent(s): 5897b48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -43
app.py CHANGED
@@ -133,13 +133,19 @@ def translate_audio_four(audio_path, src):
133
  return outputs # ์ด 5๊ฐœ (์›๋ฌธ + 4์–ธ์–ด)
134
 
135
  # =============== Gradio UI ==========================================
 
 
136
  with gr.Blocks(title="SMARTok Demo", theme=gr.themes.Soft()) as app:
137
  with gr.Tabs():
138
- # โ‘  ๋งˆ์ดํฌ ๋ฒˆ์—ญ (๋…น์Œ ํ›„ ์ผ๊ด„)
139
- with gr.TabItem("๐ŸŽ™๏ธ ๋งˆ์ดํฌ ๋ฒˆ์—ญ"):
140
  src1 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ")
141
  tgt1 = gr.Dropdown(LANGUAGES, value="English", label="์ถœ๋ ฅ")
142
- mic1 = gr.Audio(sources=["microphone"], type="filepath", label="๐ŸŽค ๋…น์Œ ํ›„ Stop")
 
 
 
 
143
  btn1 = gr.Button("๋ฒˆ์—ญ")
144
  stt1 = gr.Textbox(label="์›๋ฌธ", lines=5)
145
  tlt1 = gr.Textbox(label="๋ฒˆ์—ญ", lines=5)
@@ -151,11 +157,15 @@ with gr.Blocks(title="SMARTok Demo", theme=gr.themes.Soft()) as app:
151
  outputs=[stt1, tlt1, out1]
152
  )
153
 
154
- # โ‘ก ์˜ค๋””์˜ค ํŒŒ์ผ ๋ฒˆ์—ญ
155
- with gr.TabItem("๐ŸŽง ํŒŒ์ผ ๋ฒˆ์—ญ"):
156
  src2 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ")
157
  tgt2 = gr.Dropdown(LANGUAGES, value="English", label="์ถœ๋ ฅ")
158
- file2 = gr.Audio(sources=["upload"], type="filepath", label="์˜ค๋””์˜ค ํŒŒ์ผ ์—…๋กœ๋“œ")
 
 
 
 
159
  btn2 = gr.Button("๋ฒˆ์—ญ")
160
  stt2 = gr.Textbox(label="์›๋ฌธ", lines=5)
161
  tlt2 = gr.Textbox(label="๋ฒˆ์—ญ", lines=5)
@@ -167,43 +177,9 @@ with gr.Blocks(title="SMARTok Demo", theme=gr.themes.Soft()) as app:
167
  outputs=[stt2, tlt2, out2]
168
  )
169
 
170
- # โ‘ข ์‹ค์‹œ๊ฐ„ ์ŠคํŠธ๋ฆฌ๋ฐ ์ „์‚ฌยท๋ฒˆ์—ญ (Beta)
171
- with gr.TabItem("โฑ๏ธ ์‹ค์‹œ๊ฐ„ ๋ฒˆ์—ญ (Beta)"):
172
- gr.Markdown("๋งˆ์ดํฌ๋ฅผ ์ผœ๋ฉด 3~4์ดˆ ๋‹จ์œ„๋กœ ์ž๋ง‰์ด ๊ฐฑ์‹ ๋ฉ๋‹ˆ๋‹ค.")
173
- src3 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ")
174
- tgt3 = gr.Dropdown(LANGUAGES, value="English", label="์ถœ๋ ฅ")
175
- mic3 = gr.Audio(sources=["microphone"], streaming=True, label="๐ŸŽค ์‹ค์‹œ๊ฐ„")
176
- stt3 = gr.Textbox(label="์›๋ฌธ(์‹ค์‹œ๊ฐ„)", lines=8)
177
- tlt3 = gr.Textbox(label="๋ฒˆ์—ญ(์‹ค์‹œ๊ฐ„)", lines=8)
178
-
179
- def gen(audio, src_lang, tgt_lang):
180
- yield from stream_generator(audio, src_lang, tgt_lang)
181
-
182
- mic3.stream(gen, inputs=[src3, tgt3], outputs=[stt3, tlt3])
183
-
184
- # โ‘ฃ 4๊ฐœ๊ตญ์–ด ๋™์‹œ ๋ฒˆ์—ญ
185
- with gr.TabItem("๐ŸŒ 4๊ฐœ ์–ธ์–ด ๋™์‹œ"):
186
- gr.Markdown("์ž…๋ ฅ ์Œ์„ฑ์„ **English / Chinese(็ฎ€ไฝ“) / Thai / Russian** ๋กœ ๋™์‹œ์— ๋ฒˆ์—ญํ•ฉ๋‹ˆ๋‹ค.")
187
- src4 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ ์–ธ์–ด")
188
- aud4 = gr.Audio(
189
- sources=["microphone", "upload"],
190
- type="filepath",
191
- label="๐ŸŽค ๋…น์Œ ๋˜๋Š” ํŒŒ์ผ ์—…๋กœ๋“œ"
192
- )
193
- btn4 = gr.Button("๋ฒˆ์—ญ")
194
-
195
- with gr.Row():
196
- org4 = gr.Textbox(label="์›๋ฌธ", lines=4)
197
- en4 = gr.Textbox(label="English", lines=4)
198
- zh4 = gr.Textbox(label="Chinese (็ฎ€ไฝ“)", lines=4)
199
- th4 = gr.Textbox(label="Thai", lines=4)
200
- ru4 = gr.Textbox(label="Russian", lines=4)
201
-
202
- btn4.click(
203
- translate_audio_four,
204
- inputs=[aud4, src4],
205
- outputs=[org4, en4, zh4, th4, ru4]
206
- )
207
 
208
  # ===================== ์‹คํ–‰ ==========================================
209
  if __name__ == "__main__":
 
133
  return outputs # ์ด 5๊ฐœ (์›๋ฌธ + 4์–ธ์–ด)
134
 
135
  # =============== Gradio UI ==========================================
136
+ # โ€ฆ (์œ„์ชฝ ๊ณตํ†ต ์ดˆ๊ธฐํ™”/ํ•จ์ˆ˜ ๋™์ผ) โ€ฆ
137
+
138
  with gr.Blocks(title="SMARTok Demo", theme=gr.themes.Soft()) as app:
139
  with gr.Tabs():
140
+ # โ‘  ๋งˆ์ดํฌ + ํŒŒ์ผ ๋ฒˆ์—ญ โ† ์ˆ˜์ •
141
+ with gr.TabItem("๐ŸŽ™๏ธ ๋งˆ์ดํฌ/ํŒŒ์ผ ๋ฒˆ์—ญ"):
142
  src1 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ")
143
  tgt1 = gr.Dropdown(LANGUAGES, value="English", label="์ถœ๋ ฅ")
144
+ mic1 = gr.Audio(
145
+ sources=["microphone", "upload"], # โœ… ๋‘˜ ๋‹ค ํ—ˆ์šฉ
146
+ type="filepath",
147
+ label="๐ŸŽค ๋…น์Œ ๋˜๋Š” ์˜ค๋””์˜ค ํŒŒ์ผ ์—…๋กœ๋“œ"
148
+ )
149
  btn1 = gr.Button("๋ฒˆ์—ญ")
150
  stt1 = gr.Textbox(label="์›๋ฌธ", lines=5)
151
  tlt1 = gr.Textbox(label="๋ฒˆ์—ญ", lines=5)
 
157
  outputs=[stt1, tlt1, out1]
158
  )
159
 
160
+ # โ‘ก ์˜ค๋””์˜ค ํŒŒ์ผ ์ „์šฉ ๋ฒˆ์—ญ (๊ทธ๋Œ€๋กœ)
161
+ with gr.TabItem("๐ŸŽง ํŒŒ์ผ ์ „์šฉ ๋ฒˆ์—ญ"):
162
  src2 = gr.Dropdown(LANGUAGES, value="Korean", label="์ž…๋ ฅ")
163
  tgt2 = gr.Dropdown(LANGUAGES, value="English", label="์ถœ๋ ฅ")
164
+ file2 = gr.Audio(
165
+ sources=["upload"],
166
+ type="filepath",
167
+ label="์˜ค๋””์˜ค ํŒŒ์ผ ์—…๋กœ๋“œ"
168
+ )
169
  btn2 = gr.Button("๋ฒˆ์—ญ")
170
  stt2 = gr.Textbox(label="์›๋ฌธ", lines=5)
171
  tlt2 = gr.Textbox(label="๋ฒˆ์—ญ", lines=5)
 
177
  outputs=[stt2, tlt2, out2]
178
  )
179
 
180
+ # โ‘ข ์‹ค์‹œ๊ฐ„ ์ŠคํŠธ๋ฆฌ๋ฐ ๋ฒˆ์—ญ (Beta) โ€ฆ ์ด์ „๊ณผ ๋™์ผ โ€ฆ
181
+
182
+ # โ‘ฃ 4๊ฐœ ์–ธ์–ด ๋™์‹œ ๋ฒˆ์—ญ โ€ฆ ์ด์ „๊ณผ ๋™์ผ โ€ฆ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  # ===================== ์‹คํ–‰ ==========================================
185
  if __name__ == "__main__":