Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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(
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
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 |
-
# โข ์ค์๊ฐ ์คํธ๋ฆฌ๋ฐ
|
171 |
-
|
172 |
-
|
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__":
|