Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -55,193 +55,52 @@ class SeamlessTranslator:
|
|
55 |
raise gr.Error(f"β Translation failed: {str(e)}")
|
56 |
|
57 |
css = """
|
58 |
-
|
59 |
-
max-width: 1200px;
|
60 |
-
margin: auto;
|
61 |
-
padding: 20px;
|
62 |
}
|
63 |
|
64 |
-
.
|
65 |
-
border-radius: 16px;
|
66 |
-
padding: 24px;
|
67 |
-
background: white;
|
68 |
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
69 |
-
}
|
70 |
-
|
71 |
-
.header-container {
|
72 |
text-align: center;
|
73 |
margin-bottom: 2rem;
|
74 |
padding: 2rem;
|
75 |
-
background: linear-gradient(135deg, #f8fafc, #e2e8f0);
|
76 |
-
border-radius: 16px;
|
77 |
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
78 |
-
}
|
79 |
-
|
80 |
-
.title {
|
81 |
-
font-size: 2.75rem;
|
82 |
-
font-weight: 800;
|
83 |
background: linear-gradient(135deg, #1e40af, #3b82f6);
|
84 |
-
-webkit-background-clip: text;
|
85 |
-
-webkit-text-fill-color: transparent;
|
86 |
-
margin-bottom: 0.5rem;
|
87 |
-
}
|
88 |
-
|
89 |
-
.subtitle {
|
90 |
-
color: #64748b;
|
91 |
-
font-size: 1.1rem;
|
92 |
-
margin-bottom: 1rem;
|
93 |
-
}
|
94 |
-
|
95 |
-
.stats {
|
96 |
-
display: flex;
|
97 |
-
justify-content: center;
|
98 |
-
gap: 2rem;
|
99 |
-
margin-top: 1rem;
|
100 |
-
}
|
101 |
-
|
102 |
-
.stat-item {
|
103 |
-
text-align: center;
|
104 |
-
padding: 0.5rem 1rem;
|
105 |
-
background: white;
|
106 |
-
border-radius: 8px;
|
107 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
108 |
-
}
|
109 |
-
|
110 |
-
.stat-value {
|
111 |
-
font-weight: 600;
|
112 |
-
color: #1e40af;
|
113 |
-
font-size: 1.25rem;
|
114 |
-
}
|
115 |
-
|
116 |
-
.stat-label {
|
117 |
-
color: #64748b;
|
118 |
-
font-size: 0.875rem;
|
119 |
-
}
|
120 |
-
|
121 |
-
.tab-nav {
|
122 |
-
background: white;
|
123 |
-
padding: 0.5rem;
|
124 |
border-radius: 12px;
|
125 |
-
|
126 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
127 |
-
}
|
128 |
-
|
129 |
-
.gr-form {
|
130 |
-
border: none !important;
|
131 |
-
background: white;
|
132 |
-
padding: 1.5rem !important;
|
133 |
-
border-radius: 12px !important;
|
134 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
135 |
-
}
|
136 |
-
|
137 |
-
.gr-box {
|
138 |
-
border-radius: 12px !important;
|
139 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
140 |
-
}
|
141 |
-
|
142 |
-
.gr-button {
|
143 |
-
border-radius: 8px !important;
|
144 |
-
background: linear-gradient(135deg, #1e40af, #3b82f6) !important;
|
145 |
-
color: white !important;
|
146 |
-
font-weight: 600 !important;
|
147 |
-
padding: 0.75rem 1.5rem !important;
|
148 |
-
transition: all 0.2s !important;
|
149 |
}
|
150 |
|
151 |
-
.
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
.gr-input, .gr-select {
|
157 |
-
border-radius: 8px !important;
|
158 |
-
border: 1px solid #e2e8f0 !important;
|
159 |
-
padding: 0.75rem !important;
|
160 |
-
transition: all 0.2s !important;
|
161 |
-
}
|
162 |
-
|
163 |
-
.gr-input:focus, .gr-select:focus {
|
164 |
-
border-color: #3b82f6 !important;
|
165 |
-
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
|
166 |
}
|
167 |
|
168 |
-
.
|
169 |
-
|
170 |
-
|
171 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1) !important;
|
172 |
}
|
173 |
|
174 |
-
.
|
175 |
-
background: #f8fafc;
|
176 |
padding: 1.5rem;
|
177 |
border-radius: 12px;
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
.output-label {
|
182 |
-
font-weight: 600;
|
183 |
-
color: #1e40af;
|
184 |
-
margin-bottom: 0.75rem;
|
185 |
-
font-size: 1.1rem;
|
186 |
}
|
187 |
|
188 |
-
.status-
|
189 |
-
padding:
|
190 |
border-radius: 8px;
|
191 |
-
margin-top: 1rem;
|
192 |
-
font-size: 0.875rem;
|
193 |
background: #f0f9ff;
|
194 |
border-left: 4px solid #3b82f6;
|
|
|
195 |
}
|
196 |
|
197 |
.footer {
|
198 |
text-align: center;
|
199 |
-
margin-top:
|
200 |
-
padding: 1.5rem;
|
201 |
-
background: white;
|
202 |
-
border-radius: 12px;
|
203 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
204 |
-
}
|
205 |
-
|
206 |
-
.footer-text {
|
207 |
-
color: #64748b;
|
208 |
-
font-size: 0.875rem;
|
209 |
-
}
|
210 |
-
|
211 |
-
.feature-grid {
|
212 |
-
display: grid;
|
213 |
-
grid-template-columns: repeat(3, 1fr);
|
214 |
-
gap: 1rem;
|
215 |
-
margin: 1rem 0;
|
216 |
-
}
|
217 |
-
|
218 |
-
.feature-item {
|
219 |
-
background: white;
|
220 |
padding: 1rem;
|
221 |
-
|
222 |
-
text-align: center;
|
223 |
-
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
224 |
-
}
|
225 |
-
|
226 |
-
.feature-icon {
|
227 |
-
font-size: 1.5rem;
|
228 |
-
margin-bottom: 0.5rem;
|
229 |
-
color: #3b82f6;
|
230 |
-
}
|
231 |
-
|
232 |
-
.language-pair {
|
233 |
-
display: flex;
|
234 |
-
align-items: center;
|
235 |
-
gap: 1rem;
|
236 |
-
margin: 1rem 0;
|
237 |
-
padding: 0.75rem;
|
238 |
-
background: #f8fafc;
|
239 |
-
border-radius: 8px;
|
240 |
-
}
|
241 |
-
|
242 |
-
.language-arrow {
|
243 |
-
color: #3b82f6;
|
244 |
-
font-weight: bold;
|
245 |
}
|
246 |
"""
|
247 |
|
@@ -249,71 +108,50 @@ def create_ui():
|
|
249 |
translator = SeamlessTranslator()
|
250 |
|
251 |
with gr.Blocks(css=css, title="A.R.I.S. Translator") as demo:
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
""
|
256 |
-
<div class="
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
<div class="stat-value">10</div>
|
261 |
-
<div class="stat-label">Languages</div>
|
262 |
-
</div>
|
263 |
-
<div class="stat-item">
|
264 |
-
<div class="stat-value">Real-time</div>
|
265 |
-
<div class="stat-label">Translation</div>
|
266 |
-
</div>
|
267 |
-
<div class="stat-item">
|
268 |
-
<div class="stat-value">Neural</div>
|
269 |
-
<div class="stat-label">Technology</div>
|
270 |
-
</div>
|
271 |
-
</div>
|
272 |
-
"""
|
273 |
-
)
|
274 |
|
275 |
-
|
276 |
-
with gr.Tabs() as tabs:
|
277 |
# Text Translation Tab
|
278 |
-
with gr.Tab("π€ Text Translation"
|
279 |
with gr.Row():
|
280 |
with gr.Column():
|
281 |
text_input = gr.Textbox(
|
282 |
label="Text to Translate",
|
283 |
placeholder="Enter your text here...",
|
284 |
-
lines=5
|
285 |
-
elem_classes="gr-input"
|
286 |
)
|
287 |
with gr.Row():
|
288 |
src_lang = gr.Dropdown(
|
289 |
choices=list(translator.languages.keys()),
|
290 |
value="πΊπΈ English",
|
291 |
-
label="Source Language"
|
292 |
-
elem_classes="gr-select"
|
293 |
)
|
294 |
tgt_lang = gr.Dropdown(
|
295 |
choices=list(translator.languages.keys()),
|
296 |
value="πͺπΈ Spanish",
|
297 |
-
label="Target Language"
|
298 |
-
elem_classes="gr-select"
|
299 |
)
|
300 |
translate_btn = gr.Button("π Translate", variant="primary")
|
301 |
status_text = gr.Textbox(
|
302 |
label="Status",
|
303 |
-
interactive=False
|
304 |
-
elem_classes="status-message"
|
305 |
)
|
306 |
|
307 |
with gr.Column():
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
type="numpy"
|
313 |
-
)
|
314 |
|
315 |
# Audio Translation Tab
|
316 |
-
with gr.Tab("π€ Audio Translation"
|
317 |
with gr.Row():
|
318 |
with gr.Column():
|
319 |
audio_input = gr.Audio(
|
@@ -323,51 +161,24 @@ def create_ui():
|
|
323 |
tgt_lang_audio = gr.Dropdown(
|
324 |
choices=list(translator.languages.keys()),
|
325 |
value="πΊπΈ English",
|
326 |
-
label="Target Language"
|
327 |
-
elem_classes="gr-select"
|
328 |
)
|
329 |
translate_audio_btn = gr.Button("π Translate Audio", variant="primary")
|
330 |
status_text_audio = gr.Textbox(
|
331 |
label="Status",
|
332 |
-
interactive=False
|
333 |
-
elem_classes="status-message"
|
334 |
)
|
335 |
|
336 |
with gr.Column():
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
type="numpy"
|
342 |
-
)
|
343 |
-
|
344 |
-
# Features Grid
|
345 |
-
gr.HTML(
|
346 |
-
"""
|
347 |
-
<div class="feature-grid">
|
348 |
-
<div class="feature-item">
|
349 |
-
<div class="feature-icon">π</div>
|
350 |
-
<div>10 Languages</div>
|
351 |
-
</div>
|
352 |
-
<div class="feature-item">
|
353 |
-
<div class="feature-icon">β‘</div>
|
354 |
-
<div>Real-time Processing</div>
|
355 |
-
</div>
|
356 |
-
<div class="feature-item">
|
357 |
-
<div class="feature-icon">οΏ½οΏ½οΏ½</div>
|
358 |
-
<div>High Accuracy</div>
|
359 |
-
</div>
|
360 |
-
</div>
|
361 |
-
"""
|
362 |
-
)
|
363 |
|
364 |
-
# Footer
|
365 |
gr.HTML(
|
366 |
"""
|
367 |
<div class="footer">
|
368 |
-
|
369 |
-
Powered by Meta's SeamlessM4T model | Built with β€οΈ using Gradio
|
370 |
-
</div>
|
371 |
</div>
|
372 |
"""
|
373 |
)
|
|
|
55 |
raise gr.Error(f"β Translation failed: {str(e)}")
|
56 |
|
57 |
css = """
|
58 |
+
.gradio-container {
|
59 |
+
max-width: 1200px !important;
|
60 |
+
margin: auto !important;
|
|
|
61 |
}
|
62 |
|
63 |
+
.main-header {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
text-align: center;
|
65 |
margin-bottom: 2rem;
|
66 |
padding: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
background: linear-gradient(135deg, #1e40af, #3b82f6);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
border-radius: 12px;
|
69 |
+
color: white;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
+
.main-title {
|
73 |
+
font-size: 2.5rem;
|
74 |
+
font-weight: bold;
|
75 |
+
margin-bottom: 0.5rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
+
.main-subtitle {
|
79 |
+
font-size: 1.2rem;
|
80 |
+
opacity: 0.9;
|
|
|
81 |
}
|
82 |
|
83 |
+
.container {
|
|
|
84 |
padding: 1.5rem;
|
85 |
border-radius: 12px;
|
86 |
+
background: white;
|
87 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
88 |
+
margin-bottom: 1.5rem;
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
+
.status-box {
|
92 |
+
padding: 1rem;
|
93 |
border-radius: 8px;
|
|
|
|
|
94 |
background: #f0f9ff;
|
95 |
border-left: 4px solid #3b82f6;
|
96 |
+
margin-top: 1rem;
|
97 |
}
|
98 |
|
99 |
.footer {
|
100 |
text-align: center;
|
101 |
+
margin-top: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
padding: 1rem;
|
103 |
+
color: #666;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
"""
|
106 |
|
|
|
108 |
translator = SeamlessTranslator()
|
109 |
|
110 |
with gr.Blocks(css=css, title="A.R.I.S. Translator") as demo:
|
111 |
+
gr.HTML(
|
112 |
+
"""
|
113 |
+
<div class="main-header">
|
114 |
+
<div class="main-title">A.R.I.S. Translator</div>
|
115 |
+
<div class="main-subtitle">Advanced Real-time Interpretation System</div>
|
116 |
+
</div>
|
117 |
+
"""
|
118 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
+
with gr.Tabs():
|
|
|
121 |
# Text Translation Tab
|
122 |
+
with gr.Tab("π€ Text Translation"):
|
123 |
with gr.Row():
|
124 |
with gr.Column():
|
125 |
text_input = gr.Textbox(
|
126 |
label="Text to Translate",
|
127 |
placeholder="Enter your text here...",
|
128 |
+
lines=5
|
|
|
129 |
)
|
130 |
with gr.Row():
|
131 |
src_lang = gr.Dropdown(
|
132 |
choices=list(translator.languages.keys()),
|
133 |
value="πΊπΈ English",
|
134 |
+
label="Source Language"
|
|
|
135 |
)
|
136 |
tgt_lang = gr.Dropdown(
|
137 |
choices=list(translator.languages.keys()),
|
138 |
value="πͺπΈ Spanish",
|
139 |
+
label="Target Language"
|
|
|
140 |
)
|
141 |
translate_btn = gr.Button("π Translate", variant="primary")
|
142 |
status_text = gr.Textbox(
|
143 |
label="Status",
|
144 |
+
interactive=False
|
|
|
145 |
)
|
146 |
|
147 |
with gr.Column():
|
148 |
+
audio_output = gr.Audio(
|
149 |
+
label="Translation Output",
|
150 |
+
type="numpy"
|
151 |
+
)
|
|
|
|
|
152 |
|
153 |
# Audio Translation Tab
|
154 |
+
with gr.Tab("π€ Audio Translation"):
|
155 |
with gr.Row():
|
156 |
with gr.Column():
|
157 |
audio_input = gr.Audio(
|
|
|
161 |
tgt_lang_audio = gr.Dropdown(
|
162 |
choices=list(translator.languages.keys()),
|
163 |
value="πΊπΈ English",
|
164 |
+
label="Target Language"
|
|
|
165 |
)
|
166 |
translate_audio_btn = gr.Button("π Translate Audio", variant="primary")
|
167 |
status_text_audio = gr.Textbox(
|
168 |
label="Status",
|
169 |
+
interactive=False
|
|
|
170 |
)
|
171 |
|
172 |
with gr.Column():
|
173 |
+
audio_output_from_audio = gr.Audio(
|
174 |
+
label="Translation Output",
|
175 |
+
type="numpy"
|
176 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
|
|
178 |
gr.HTML(
|
179 |
"""
|
180 |
<div class="footer">
|
181 |
+
Powered by Meta's SeamlessM4T model | Built with Gradio
|
|
|
|
|
182 |
</div>
|
183 |
"""
|
184 |
)
|