openfree commited on
Commit
986a905
ยท
verified ยท
1 Parent(s): 4692c48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +197 -18
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="Multilingual TTS") as demo:
475
- gr.HTML("<center><h1>Multilingual TTS (Edge TTS)</h1></center>")
476
- gr.HTML(f"<h2 style='color:Tomato;'> {len(language_dict)} languages supported</h3>")
477
- gr.HTML(f"<p> {', '.join(language_dict.keys())} </h3>")
478
- gr.Markdown("**Note:** A special feature is added for Arabic language only.")
479
- with gr.Row():
480
- with gr.Column():
481
- input_text = gr.Textbox(lines=5, label="Input Text", placeholder="Enter text to convert to speech")
482
- language = gr.Dropdown(
483
- choices=list(language_dict.keys()), value=default_language, label="Languages", interactive=True
484
- )
485
- speaker = gr.Dropdown(choices=[], value=default_speaker, label="Speakers", interactive=False)
486
- tashkeel_checkbox = gr.Checkbox(label="Tashkeel", value=False, visible=False, interactive=False)
487
- run_btn = gr.Button(value="Generate Audio", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
 
489
- with gr.Column():
490
- output_text = gr.Textbox(label="Output Text")
491
- output_audio = gr.Audio(type="filepath", label="Audio Output")
 
 
 
 
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)