Update app.py
Browse files
app.py
CHANGED
|
@@ -103,7 +103,7 @@ def translate_and_speak_sync_wrapper(persian_text, english_tts_voice_key, rate,
|
|
| 103 |
logging.info(f"Wrapper called. Text: '{persian_text[:30]}...' Voice: {english_tts_voice_key}")
|
| 104 |
loop = get_event_loop()
|
| 105 |
audio_file_to_clean = None
|
| 106 |
-
status_update = gr.update(value=None, visible=False)
|
| 107 |
|
| 108 |
if not GOOGLE_API_KEY or not model:
|
| 109 |
msg = "خطا: سرویس ترجمه پیکربندی نشده است. لطفاً از تنظیم GOOGLE_API_KEY اطمینان حاصل کنید."
|
|
@@ -158,16 +158,16 @@ def translate_and_speak_sync_wrapper(persian_text, english_tts_voice_key, rate,
|
|
| 158 |
return f"خطای داخلی سرور: {type(e).__name__}", None, status_update
|
| 159 |
|
| 160 |
# --- تعریف تم و CSS بسیار زیباتر ---
|
| 161 |
-
FLY_PRIMARY_COLOR_HEX = "#4F46E5"
|
| 162 |
-
FLY_SECONDARY_COLOR_HEX = "#10B981"
|
| 163 |
-
FLY_ACCENT_COLOR_HEX = "#F59E0B"
|
| 164 |
-
FLY_TEXT_COLOR_HEX = "#111827"
|
| 165 |
-
FLY_SUBTLE_TEXT_HEX = "#6B7280"
|
| 166 |
-
FLY_LIGHT_BACKGROUND_HEX = "#F9FAFB"
|
| 167 |
FLY_WHITE_HEX = "#FFFFFF"
|
| 168 |
-
FLY_BORDER_COLOR_HEX = "#D1D5DB"
|
| 169 |
FLY_INPUT_BG_HEX = "#FFFFFF"
|
| 170 |
-
FLY_PANEL_BG_HEX = "#E0E7FF"
|
| 171 |
|
| 172 |
app_theme = gr.themes.Base(
|
| 173 |
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
|
@@ -175,6 +175,7 @@ app_theme = gr.themes.Base(
|
|
| 175 |
body_background_fill=FLY_LIGHT_BACKGROUND_HEX,
|
| 176 |
)
|
| 177 |
|
|
|
|
| 178 |
custom_css = f"""
|
| 179 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
| 180 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');
|
|
@@ -202,8 +203,8 @@ custom_css = f"""
|
|
| 202 |
--shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
|
| 203 |
--transition-fast: all 0.15s ease-in-out;
|
| 204 |
--transition-normal: all 0.25s ease-in-out;
|
| 205 |
-
--fly-primary-rgb: 79, 70, 229;
|
| 206 |
-
--fly-accent-rgb: 245, 158, 11;
|
| 207 |
}}
|
| 208 |
|
| 209 |
body {{font-family: var(--font-global); direction: rtl; background-color: var(--fly-bg-light); color: var(--fly-text-primary); line-height: 1.7; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-size: 16px;}}
|
|
@@ -216,22 +217,22 @@ body {{font-family: var(--font-global); direction: rtl; background-color: var(--
|
|
| 216 |
|
| 217 |
.main-content-area-fly {{
|
| 218 |
flex-grow: 1;
|
| 219 |
-
padding: 0.75rem;
|
| 220 |
width: 100%;
|
| 221 |
margin: 0 auto;
|
| 222 |
-
box-sizing: border-box;
|
| 223 |
}}
|
| 224 |
.content-panel {{
|
| 225 |
background-color: var(--fly-bg-white);
|
| 226 |
-
padding: 1rem;
|
| 227 |
border-radius: var(--radius-xl);
|
| 228 |
box-shadow: var(--shadow-xl);
|
| 229 |
margin-top: -2rem;
|
| 230 |
position: relative;
|
| 231 |
z-index: 10;
|
| 232 |
margin-bottom: 2rem;
|
| 233 |
-
width: 100%;
|
| 234 |
-
box-sizing: border-box;
|
| 235 |
}}
|
| 236 |
|
| 237 |
.gr-input > label > span.label-text, .gr-dropdown > label > span.label-text, .gr-slider > label > span.label-text {{font-weight: 600 !important; color: var(--fly-text-primary) !important; font-size: 0.9em !important; margin-bottom: 0.5rem !important; display: block;}}
|
|
@@ -269,19 +270,17 @@ div#examples_section .gr-sample-button:hover, div#examples_section table tbody t
|
|
| 269 |
.app-footer-fly {{text-align:center; font-size:0.85em; color: var(--fly-text-secondary); margin-top:2.5rem; padding: 1rem 0; background-color: rgba(255,255,255,0.3); backdrop-filter: blur(5px); border-top: 1px solid var(--fly-border-color);}}
|
| 270 |
footer, .gradio-footer {{display: none !important;}}
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
}
|
| 282 |
|
| 283 |
-
|
| 284 |
-
@media (min-width: 768px) {
|
| 285 |
.main-content-columns-fly {{display: flex; flex-direction: row; gap: 2rem; align-items: flex-start;}}
|
| 286 |
.main-content-columns-fly > .gr-column:nth-child(1) {{flex: 3;}}
|
| 287 |
.main-content-columns-fly > .gr-column:nth-child(2) {{flex: 2; position: sticky; top: 1.5rem;}}
|
|
@@ -289,7 +288,7 @@ footer, .gradio-footer {{display: none !important;}}
|
|
| 289 |
.app-title-card h1 {{font-size: 2.75em !important;}}
|
| 290 |
.app-title-card p {{font-size: 1.1em !important;}}
|
| 291 |
.content-panel {{ padding: 2rem; }}
|
| 292 |
-
}
|
| 293 |
"""
|
| 294 |
|
| 295 |
default_english_tts_voice = 'انگلیسی (آمریکا) - جنی (زن)'
|
|
|
|
| 103 |
logging.info(f"Wrapper called. Text: '{persian_text[:30]}...' Voice: {english_tts_voice_key}")
|
| 104 |
loop = get_event_loop()
|
| 105 |
audio_file_to_clean = None
|
| 106 |
+
status_update = gr.update(value=None, visible=False)
|
| 107 |
|
| 108 |
if not GOOGLE_API_KEY or not model:
|
| 109 |
msg = "خطا: سرویس ترجمه پیکربندی نشده است. لطفاً از تنظیم GOOGLE_API_KEY اطمینان حاصل کنید."
|
|
|
|
| 158 |
return f"خطای داخلی سرور: {type(e).__name__}", None, status_update
|
| 159 |
|
| 160 |
# --- تعریف تم و CSS بسیار زیباتر ---
|
| 161 |
+
FLY_PRIMARY_COLOR_HEX = "#4F46E5"
|
| 162 |
+
FLY_SECONDARY_COLOR_HEX = "#10B981"
|
| 163 |
+
FLY_ACCENT_COLOR_HEX = "#F59E0B"
|
| 164 |
+
FLY_TEXT_COLOR_HEX = "#111827"
|
| 165 |
+
FLY_SUBTLE_TEXT_HEX = "#6B7280"
|
| 166 |
+
FLY_LIGHT_BACKGROUND_HEX = "#F9FAFB"
|
| 167 |
FLY_WHITE_HEX = "#FFFFFF"
|
| 168 |
+
FLY_BORDER_COLOR_HEX = "#D1D5DB"
|
| 169 |
FLY_INPUT_BG_HEX = "#FFFFFF"
|
| 170 |
+
FLY_PANEL_BG_HEX = "#E0E7FF"
|
| 171 |
|
| 172 |
app_theme = gr.themes.Base(
|
| 173 |
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
|
|
|
| 175 |
body_background_fill=FLY_LIGHT_BACKGROUND_HEX,
|
| 176 |
)
|
| 177 |
|
| 178 |
+
# CSS بدون کامنتهای /* ... */
|
| 179 |
custom_css = f"""
|
| 180 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
| 181 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');
|
|
|
|
| 203 |
--shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
|
| 204 |
--transition-fast: all 0.15s ease-in-out;
|
| 205 |
--transition-normal: all 0.25s ease-in-out;
|
| 206 |
+
--fly-primary-rgb: 79, 70, 229;
|
| 207 |
+
--fly-accent-rgb: 245, 158, 11;
|
| 208 |
}}
|
| 209 |
|
| 210 |
body {{font-family: var(--font-global); direction: rtl; background-color: var(--fly-bg-light); color: var(--fly-text-primary); line-height: 1.7; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-size: 16px;}}
|
|
|
|
| 217 |
|
| 218 |
.main-content-area-fly {{
|
| 219 |
flex-grow: 1;
|
| 220 |
+
padding: 0.75rem;
|
| 221 |
width: 100%;
|
| 222 |
margin: 0 auto;
|
| 223 |
+
box-sizing: border-box;
|
| 224 |
}}
|
| 225 |
.content-panel {{
|
| 226 |
background-color: var(--fly-bg-white);
|
| 227 |
+
padding: 1rem;
|
| 228 |
border-radius: var(--radius-xl);
|
| 229 |
box-shadow: var(--shadow-xl);
|
| 230 |
margin-top: -2rem;
|
| 231 |
position: relative;
|
| 232 |
z-index: 10;
|
| 233 |
margin-bottom: 2rem;
|
| 234 |
+
width: 100%;
|
| 235 |
+
box-sizing: border-box;
|
| 236 |
}}
|
| 237 |
|
| 238 |
.gr-input > label > span.label-text, .gr-dropdown > label > span.label-text, .gr-slider > label > span.label-text {{font-weight: 600 !important; color: var(--fly-text-primary) !important; font-size: 0.9em !important; margin-bottom: 0.5rem !important; display: block;}}
|
|
|
|
| 270 |
.app-footer-fly {{text-align:center; font-size:0.85em; color: var(--fly-text-secondary); margin-top:2.5rem; padding: 1rem 0; background-color: rgba(255,255,255,0.3); backdrop-filter: blur(5px); border-top: 1px solid var(--fly-border-color);}}
|
| 271 |
footer, .gradio-footer {{display: none !important;}}
|
| 272 |
|
| 273 |
+
@media (min-width: 640px) {{
|
| 274 |
+
.main-content-area-fly {{
|
| 275 |
+
padding: 1.5rem;
|
| 276 |
+
max-width: 900px;
|
| 277 |
+
}}
|
| 278 |
+
.content-panel {{
|
| 279 |
+
padding: 1.5rem;
|
| 280 |
+
}}
|
| 281 |
+
}}
|
|
|
|
| 282 |
|
| 283 |
+
@media (min-width: 768px) {{
|
|
|
|
| 284 |
.main-content-columns-fly {{display: flex; flex-direction: row; gap: 2rem; align-items: flex-start;}}
|
| 285 |
.main-content-columns-fly > .gr-column:nth-child(1) {{flex: 3;}}
|
| 286 |
.main-content-columns-fly > .gr-column:nth-child(2) {{flex: 2; position: sticky; top: 1.5rem;}}
|
|
|
|
| 288 |
.app-title-card h1 {{font-size: 2.75em !important;}}
|
| 289 |
.app-title-card p {{font-size: 1.1em !important;}}
|
| 290 |
.content-panel {{ padding: 2rem; }}
|
| 291 |
+
}}
|
| 292 |
"""
|
| 293 |
|
| 294 |
default_english_tts_voice = 'انگلیسی (آمریکا) - جنی (زن)'
|