Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -469,29 +469,208 @@ def get_speakers(language):
|
|
469 |
return gr.Dropdown(choices=speakers, value=speakers[0], interactive=True), gr.Checkbox(visible=language == "Arabic", interactive=True)
|
470 |
|
471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
default_language = None
|
473 |
default_speaker = None
|
474 |
-
with gr.Blocks(title="
|
475 |
-
gr.
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
492 |
|
493 |
language.change(get_speakers, inputs=[language], outputs=[speaker, tashkeel_checkbox])
|
494 |
run_btn.click(text_to_speech_edge, inputs=[input_text, language, speaker, tashkeel_checkbox], outputs=[output_text, output_audio])
|
495 |
|
496 |
if __name__ == "__main__":
|
497 |
-
demo.queue().launch(share=True)
|
|
|
469 |
return gr.Dropdown(choices=speakers, value=speakers[0], interactive=True), gr.Checkbox(visible=language == "Arabic", interactive=True)
|
470 |
|
471 |
|
472 |
+
# Custom CSS for styling
|
473 |
+
custom_css = """
|
474 |
+
.gradio-container {
|
475 |
+
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e8ba3 100%);
|
476 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
477 |
+
}
|
478 |
+
|
479 |
+
.main-header {
|
480 |
+
background: rgba(255, 255, 255, 0.1);
|
481 |
+
backdrop-filter: blur(10px);
|
482 |
+
border-radius: 20px;
|
483 |
+
padding: 30px;
|
484 |
+
margin-bottom: 30px;
|
485 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
486 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
487 |
+
}
|
488 |
+
|
489 |
+
.header-title {
|
490 |
+
color: white;
|
491 |
+
text-align: center;
|
492 |
+
font-size: 3em;
|
493 |
+
font-weight: 700;
|
494 |
+
margin-bottom: 10px;
|
495 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
496 |
+
}
|
497 |
+
|
498 |
+
.header-subtitle {
|
499 |
+
color: #ffd700;
|
500 |
+
text-align: center;
|
501 |
+
font-size: 1.5em;
|
502 |
+
font-weight: 500;
|
503 |
+
margin-bottom: 15px;
|
504 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
|
505 |
+
}
|
506 |
+
|
507 |
+
.language-info {
|
508 |
+
color: white;
|
509 |
+
text-align: center;
|
510 |
+
font-size: 1.1em;
|
511 |
+
line-height: 1.8;
|
512 |
+
opacity: 0.9;
|
513 |
+
}
|
514 |
+
|
515 |
+
.input-container, .output-container {
|
516 |
+
background: rgba(255, 255, 255, 0.95);
|
517 |
+
border-radius: 15px;
|
518 |
+
padding: 25px;
|
519 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
|
520 |
+
margin-bottom: 20px;
|
521 |
+
}
|
522 |
+
|
523 |
+
.section-title {
|
524 |
+
color: #1e3c72;
|
525 |
+
font-size: 1.3em;
|
526 |
+
font-weight: 600;
|
527 |
+
margin-bottom: 15px;
|
528 |
+
display: flex;
|
529 |
+
align-items: center;
|
530 |
+
gap: 10px;
|
531 |
+
}
|
532 |
+
|
533 |
+
label {
|
534 |
+
color: #2a5298 !important;
|
535 |
+
font-weight: 600 !important;
|
536 |
+
font-size: 1.1em !important;
|
537 |
+
}
|
538 |
+
|
539 |
+
textarea, .dropdown {
|
540 |
+
border: 2px solid #e0e0e0 !important;
|
541 |
+
border-radius: 10px !important;
|
542 |
+
transition: all 0.3s ease !important;
|
543 |
+
}
|
544 |
+
|
545 |
+
textarea:focus, .dropdown:focus {
|
546 |
+
border-color: #2a5298 !important;
|
547 |
+
box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1) !important;
|
548 |
+
}
|
549 |
+
|
550 |
+
.gr-button-primary {
|
551 |
+
background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%) !important;
|
552 |
+
border: none !important;
|
553 |
+
border-radius: 10px !important;
|
554 |
+
font-size: 1.2em !important;
|
555 |
+
font-weight: 600 !important;
|
556 |
+
padding: 12px 30px !important;
|
557 |
+
transition: all 0.3s ease !important;
|
558 |
+
}
|
559 |
+
|
560 |
+
.gr-button-primary:hover {
|
561 |
+
transform: translateY(-2px) !important;
|
562 |
+
box-shadow: 0 5px 20px rgba(30, 60, 114, 0.4) !important;
|
563 |
+
}
|
564 |
+
|
565 |
+
.special-note {
|
566 |
+
background: rgba(255, 235, 59, 0.2);
|
567 |
+
border-left: 4px solid #ffd700;
|
568 |
+
padding: 15px;
|
569 |
+
border-radius: 8px;
|
570 |
+
color: white;
|
571 |
+
margin: 20px 0;
|
572 |
+
}
|
573 |
+
|
574 |
+
.footer-info {
|
575 |
+
text-align: center;
|
576 |
+
color: white;
|
577 |
+
opacity: 0.8;
|
578 |
+
margin-top: 30px;
|
579 |
+
font-size: 0.9em;
|
580 |
+
}
|
581 |
+
"""
|
582 |
+
|
583 |
default_language = None
|
584 |
default_speaker = None
|
585 |
+
with gr.Blocks(title="๋ค๊ตญ์ด ์์ฑ ์์ฑ๊ธฐ(TTS)", css=custom_css) as demo:
|
586 |
+
with gr.Column():
|
587 |
+
# Header Section
|
588 |
+
gr.HTML("""
|
589 |
+
<div class="main-header">
|
590 |
+
<h1 class="header-title">๐ ๋ค๊ตญ์ด ์์ฑ ์์ฑ๊ธฐ (TTS)</h1>
|
591 |
+
<h2 class="header-subtitle">74๊ฐ ์ธ์ด ์ง์ | Edge TTS ๊ธฐ๋ฐ</h2>
|
592 |
+
<p class="language-info">
|
593 |
+
<strong>์ง์ ์ธ์ด:</strong><br>
|
594 |
+
English, Spanish, Arabic, Korean, Thai, Vietnamese, Japanese, French, Portuguese,
|
595 |
+
Indonesian, Hebrew, Italian, Dutch, Malay, Norwegian, Swedish, Greek, German,
|
596 |
+
Afrikaans, Amharic, Azerbaijani, Bulgarian, Bengali, Bosnian, Catalan, Czech,
|
597 |
+
Welsh, Danish, Estonian, Persian, Finnish, Irish, Galician, Gujarati, Hindi,
|
598 |
+
Croatian, Hungarian, Icelandic, Javanese, Georgian, Kazakh, Khmer, Kannada,
|
599 |
+
Lao, Lithuanian, Latvian, Macedonian, Malayalam, Mongolian, Marathi, Maltese,
|
600 |
+
Burmese, Nepali, Polish, Pashto, Romanian, Russian, Sinhala, Slovak, Slovenian,
|
601 |
+
Somali, Albanian, Serbian, Sundanese, Swahili, Tamil, Telugu, Turkish, Ukrainian,
|
602 |
+
Urdu, Uzbek, Mandarin, Zulu
|
603 |
+
</p>
|
604 |
+
</div>
|
605 |
+
""")
|
606 |
+
|
607 |
+
# Special Note for Arabic
|
608 |
+
gr.HTML("""
|
609 |
+
<div class="special-note">
|
610 |
+
<strong>โจ ํน๋ณ ๊ธฐ๋ฅ:</strong> ์๋์ด์ ๊ฒฝ์ฐ ์๋ Tashkeel (๋ฐ์ ๋ถํธ) ์ถ๊ฐ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
|
611 |
+
</div>
|
612 |
+
""")
|
613 |
+
|
614 |
+
with gr.Row():
|
615 |
+
# Input Section
|
616 |
+
with gr.Column(scale=1):
|
617 |
+
gr.HTML('<div class="section-title">๐ ์
๋ ฅ ์ค์ </div>')
|
618 |
+
with gr.Column(elem_classes="input-container"):
|
619 |
+
input_text = gr.Textbox(
|
620 |
+
lines=6,
|
621 |
+
label="ํ
์คํธ ์
๋ ฅ",
|
622 |
+
placeholder="์์ฑ์ผ๋ก ๋ณํํ ํ
์คํธ๋ฅผ ์
๋ ฅํ์ธ์...\nEnter text to convert to speech...",
|
623 |
+
elem_classes="input-textarea"
|
624 |
+
)
|
625 |
+
language = gr.Dropdown(
|
626 |
+
choices=list(language_dict.keys()),
|
627 |
+
value=default_language,
|
628 |
+
label="์ธ์ด ์ ํ",
|
629 |
+
interactive=True
|
630 |
+
)
|
631 |
+
speaker = gr.Dropdown(
|
632 |
+
choices=[],
|
633 |
+
value=default_speaker,
|
634 |
+
label="์์ฑ ์ ํ",
|
635 |
+
interactive=False
|
636 |
+
)
|
637 |
+
tashkeel_checkbox = gr.Checkbox(
|
638 |
+
label="Tashkeel ์ ์ฉ (์๋์ด ์ ์ฉ)",
|
639 |
+
value=False,
|
640 |
+
visible=False,
|
641 |
+
interactive=False
|
642 |
+
)
|
643 |
+
run_btn = gr.Button(
|
644 |
+
value="๐๏ธ ์์ฑ ์์ฑ",
|
645 |
+
variant="primary",
|
646 |
+
size="lg"
|
647 |
+
)
|
648 |
+
|
649 |
+
# Output Section
|
650 |
+
with gr.Column(scale=1):
|
651 |
+
gr.HTML('<div class="section-title">๐ ์ถ๋ ฅ ๊ฒฐ๊ณผ</div>')
|
652 |
+
with gr.Column(elem_classes="output-container"):
|
653 |
+
output_text = gr.Textbox(
|
654 |
+
label="์ฒ๋ฆฌ๋ ํ
์คํธ",
|
655 |
+
lines=6,
|
656 |
+
interactive=False
|
657 |
+
)
|
658 |
+
output_audio = gr.Audio(
|
659 |
+
type="filepath",
|
660 |
+
label="์์ฑ๋ ์์ฑ",
|
661 |
+
elem_classes="audio-output"
|
662 |
+
)
|
663 |
|
664 |
+
# Footer
|
665 |
+
gr.HTML("""
|
666 |
+
<div class="footer-info">
|
667 |
+
<p>๐ก Tip: ๊ฐ ์ธ์ด๋ณ๋ก ๋ค์ํ ์์ฑ ์ต์
์ ์ ํํ ์ ์์ต๋๋ค.
|
668 |
+
์์ฐ์ค๋ฌ์ด ์ต์๊ณผ ๋ฐ์์ ์ํด ์์ด๋ฏผ ํ์ ์์ฑ์ ์ ๊ณตํฉ๋๋ค.</p>
|
669 |
+
</div>
|
670 |
+
""")
|
671 |
|
672 |
language.change(get_speakers, inputs=[language], outputs=[speaker, tashkeel_checkbox])
|
673 |
run_btn.click(text_to_speech_edge, inputs=[input_text, language, speaker, tashkeel_checkbox], outputs=[output_text, output_audio])
|
674 |
|
675 |
if __name__ == "__main__":
|
676 |
+
demo.queue().launch(share=True)
|