romizone commited on
Commit
ecbce41
·
verified ·
1 Parent(s): 6594485

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +235 -47
app.py CHANGED
@@ -497,58 +497,242 @@ THEME = gr.themes.Base(
497
  input_border_color_dark="#333340",
498
  )
499
 
500
- with gr.Blocks(theme=THEME, title="TranscribeAI", css="""
501
- .gradio-container { max-width: 900px !important; }
502
- .gr-button-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6) !important; }
503
- footer { display: none !important; }
504
- """) as demo:
505
-
506
- gr.Markdown("""
507
- # TranscribeAI
508
- **Transkripsi Audio + Speaker Diarization — GPU Accelerated (ZeroGPU H200)**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  """)
510
 
511
- with gr.Row():
512
- with gr.Column(scale=2):
513
- audio_input = gr.Audio(
514
- label="Upload Audio/Video",
515
- type="filepath",
516
- sources=["upload", "microphone"],
517
- )
518
- with gr.Column(scale=1):
519
- model_choice = gr.Dropdown(
520
- choices=list(WHISPER_MODELS.keys()),
521
- value="small",
522
- label="Model",
523
- info="Lebih besar = lebih akurat tapi lebih lambat"
524
- )
525
- language_choice = gr.Dropdown(
526
- choices=list(LANGUAGE_MAP.keys()),
527
- value="Auto-detect",
528
- label="Bahasa"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  )
530
- speaker_count = gr.Slider(
531
- minimum=0, maximum=10, step=1, value=0,
532
- label="Jumlah Pembicara (0 = auto)",
 
533
  )
534
 
535
- with gr.Row():
536
- enable_diarization = gr.Checkbox(value=True, label="Speaker Diarization")
537
- enable_vad = gr.Checkbox(value=True, label="VAD Filter")
538
-
539
- btn_start = gr.Button("Mulai Transkripsi", variant="primary", size="lg")
540
-
541
- summary_output = gr.Markdown(label="Ringkasan")
542
- transcript_output = gr.Textbox(
543
- label="Hasil Transkripsi", lines=15,
544
- show_copy_button=True, interactive=False,
545
  )
546
 
547
- with gr.Row():
548
- srt_file = gr.File(label="Download SRT")
549
- txt_file = gr.File(label="Download TXT")
550
- docx_file = gr.File(label="Download DOCX")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
 
 
552
  btn_start.click(
553
  fn=transcribe_full,
554
  inputs=[audio_input, model_choice, language_choice, speaker_count,
@@ -556,9 +740,13 @@ with gr.Blocks(theme=THEME, title="TranscribeAI", css="""
556
  outputs=[summary_output, transcript_output, srt_file, txt_file, docx_file],
557
  )
558
 
559
- gr.Markdown("""
560
- ---
561
- **TranscribeAI** by [romizone](https://huggingface.co/romizone) | ZeroGPU H200 | [GitHub](https://github.com/romizone/transcribeAI)
 
 
 
 
562
  """)
563
 
564
  demo.queue().launch(ssr_mode=False)
 
497
  input_border_color_dark="#333340",
498
  )
499
 
500
+ CUSTOM_CSS = """
501
+ /* Global */
502
+ .gradio-container {
503
+ max-width: 960px !important;
504
+ margin: 0 auto !important;
505
+ }
506
+ footer { display: none !important; }
507
+
508
+ /* Header */
509
+ .header-wrap {
510
+ text-align: center;
511
+ padding: 32px 0 20px;
512
+ }
513
+ .header-wrap h1 {
514
+ font-size: 32px !important;
515
+ font-weight: 800 !important;
516
+ background: linear-gradient(135deg, #818cf8, #8b5cf6) !important;
517
+ -webkit-background-clip: text !important;
518
+ -webkit-text-fill-color: transparent !important;
519
+ background-clip: text !important;
520
+ letter-spacing: -0.5px;
521
+ margin-bottom: 6px !important;
522
+ }
523
+ .header-wrap p {
524
+ color: #a0a0b0 !important;
525
+ font-size: 14px !important;
526
+ }
527
+ .badge-gpu {
528
+ display: inline-flex;
529
+ align-items: center;
530
+ gap: 6px;
531
+ background: rgba(99,102,241,.12);
532
+ color: #818cf8;
533
+ font-size: 12px;
534
+ padding: 4px 14px;
535
+ border-radius: 20px;
536
+ font-weight: 600;
537
+ margin-top: 8px;
538
+ }
539
+ .badge-gpu::before {
540
+ content: '';
541
+ width: 7px;
542
+ height: 7px;
543
+ background: #10b981;
544
+ border-radius: 50%;
545
+ display: inline-block;
546
+ }
547
+
548
+ /* Cards */
549
+ .card-section {
550
+ background: #1a1a1f !important;
551
+ border: 1px solid #333340 !important;
552
+ border-radius: 14px !important;
553
+ padding: 20px 24px !important;
554
+ margin-bottom: 12px !important;
555
+ }
556
+ .card-title {
557
+ font-size: 14px !important;
558
+ font-weight: 700 !important;
559
+ color: #e8e8ed !important;
560
+ margin-bottom: 12px !important;
561
+ display: flex;
562
+ align-items: center;
563
+ gap: 8px;
564
+ }
565
+
566
+ /* Primary button */
567
+ .btn-start {
568
+ background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
569
+ border: none !important;
570
+ border-radius: 12px !important;
571
+ font-size: 16px !important;
572
+ font-weight: 700 !important;
573
+ padding: 14px 32px !important;
574
+ transition: all 0.2s !important;
575
+ box-shadow: 0 4px 15px rgba(99,102,241,.3) !important;
576
+ }
577
+ .btn-start:hover {
578
+ transform: translateY(-1px) !important;
579
+ box-shadow: 0 6px 20px rgba(99,102,241,.4) !important;
580
+ }
581
+
582
+ /* Settings grid */
583
+ .settings-row {
584
+ gap: 8px !important;
585
+ }
586
+
587
+ /* Transcript output */
588
+ .transcript-box textarea {
589
+ font-family: 'Inter', 'SF Mono', monospace !important;
590
+ font-size: 13px !important;
591
+ line-height: 1.7 !important;
592
+ background: #16161a !important;
593
+ border-radius: 10px !important;
594
+ }
595
+
596
+ /* Download cards */
597
+ .download-row .file-preview {
598
+ background: #1a1a1f !important;
599
+ border: 1px solid #333340 !important;
600
+ border-radius: 10px !important;
601
+ }
602
+
603
+ /* Result summary */
604
+ .summary-box {
605
+ background: #1a1a1f !important;
606
+ border: 1px solid #2a2a35 !important;
607
+ border-radius: 12px !important;
608
+ padding: 16px !important;
609
+ }
610
+ .summary-box table {
611
+ width: 100% !important;
612
+ }
613
+ .summary-box td, .summary-box th {
614
+ padding: 6px 12px !important;
615
+ font-size: 13px !important;
616
+ border-bottom: 1px solid #222230 !important;
617
+ }
618
+
619
+ /* Toggle checkboxes */
620
+ .toggle-row {
621
+ gap: 24px !important;
622
+ }
623
+
624
+ /* Audio upload area */
625
+ .audio-upload {
626
+ border: 2px dashed #333340 !important;
627
+ border-radius: 14px !important;
628
+ transition: all 0.2s !important;
629
+ }
630
+ .audio-upload:hover {
631
+ border-color: #6366f1 !important;
632
+ }
633
+
634
+ /* Footer */
635
+ .footer-text {
636
+ text-align: center;
637
+ padding: 20px 0 8px;
638
+ color: #6a6a7a;
639
+ font-size: 12px;
640
+ }
641
+ .footer-text a {
642
+ color: #818cf8;
643
+ text-decoration: none;
644
+ }
645
+ """
646
+
647
+ with gr.Blocks(theme=THEME, title="TranscribeAI", css=CUSTOM_CSS) as demo:
648
+
649
+ # ---- Header ----
650
+ gr.HTML("""
651
+ <div class="header-wrap">
652
+ <h1>TranscribeAI</h1>
653
+ <p>Transkripsi Audio dengan Speaker Diarization</p>
654
+ <div class="badge-gpu">ZeroGPU H200 &bull; Whisper &bull; Tanpa API Key</div>
655
+ </div>
656
  """)
657
 
658
+ # ---- Upload + Settings ----
659
+ with gr.Group(elem_classes="card-section"):
660
+ gr.HTML('<div class="card-title">🎵 Upload & Pengaturan</div>')
661
+ with gr.Row():
662
+ with gr.Column(scale=3):
663
+ audio_input = gr.Audio(
664
+ label="Upload Audio / Video / Rekam",
665
+ type="filepath",
666
+ sources=["upload", "microphone"],
667
+ elem_classes="audio-upload",
668
+ )
669
+ with gr.Column(scale=2, elem_classes="settings-row"):
670
+ model_choice = gr.Dropdown(
671
+ choices=list(WHISPER_MODELS.keys()),
672
+ value="small",
673
+ label="Model Whisper",
674
+ info="tiny (cepat) → large-v3 (akurat)"
675
+ )
676
+ language_choice = gr.Dropdown(
677
+ choices=list(LANGUAGE_MAP.keys()),
678
+ value="Auto-detect",
679
+ label="Bahasa",
680
+ )
681
+ speaker_count = gr.Slider(
682
+ minimum=0, maximum=10, step=1, value=0,
683
+ label="Jumlah Pembicara",
684
+ info="0 = auto-detect"
685
+ )
686
+
687
+ # ---- Options ----
688
+ with gr.Group(elem_classes="card-section"):
689
+ gr.HTML('<div class="card-title">⚙️ Opsi</div>')
690
+ with gr.Row(elem_classes="toggle-row"):
691
+ enable_diarization = gr.Checkbox(
692
+ value=True,
693
+ label="Speaker Diarization",
694
+ info="Identifikasi siapa yang berbicara"
695
  )
696
+ enable_vad = gr.Checkbox(
697
+ value=True,
698
+ label="VAD Filter",
699
+ info="Lewati bagian hening"
700
  )
701
 
702
+ # ---- Start Button ----
703
+ btn_start = gr.Button(
704
+ "🚀 Mulai Transkripsi",
705
+ variant="primary",
706
+ size="lg",
707
+ elem_classes="btn-start",
 
 
 
 
708
  )
709
 
710
+ # ---- Results ----
711
+ with gr.Group(elem_classes="card-section", visible=True):
712
+ gr.HTML('<div class="card-title">📊 Hasil</div>')
713
+ summary_output = gr.Markdown(
714
+ label="Ringkasan",
715
+ elem_classes="summary-box",
716
+ )
717
+ transcript_output = gr.Textbox(
718
+ label="Transkripsi",
719
+ lines=18,
720
+ max_lines=40,
721
+ show_copy_button=True,
722
+ interactive=False,
723
+ elem_classes="transcript-box",
724
+ placeholder="Hasil transkripsi akan muncul di sini...",
725
+ )
726
+
727
+ # ---- Downloads ----
728
+ with gr.Group(elem_classes="card-section"):
729
+ gr.HTML('<div class="card-title">📥 Download</div>')
730
+ with gr.Row(elem_classes="download-row"):
731
+ srt_file = gr.File(label="SRT (Subtitle)")
732
+ txt_file = gr.File(label="TXT (Teks)")
733
+ docx_file = gr.File(label="DOCX (Dokumen)")
734
 
735
+ # ---- Connect ----
736
  btn_start.click(
737
  fn=transcribe_full,
738
  inputs=[audio_input, model_choice, language_choice, speaker_count,
 
740
  outputs=[summary_output, transcript_output, srt_file, txt_file, docx_file],
741
  )
742
 
743
+ # ---- Footer ----
744
+ gr.HTML("""
745
+ <div class="footer-text">
746
+ <strong>TranscribeAI</strong> by <a href="https://huggingface.co/romizone">romizone</a>
747
+ &bull; <a href="https://github.com/romizone/transcribeAI">GitHub</a>
748
+ &bull; ZeroGPU H200 &bull; Whisper + PyTorch
749
+ </div>
750
  """)
751
 
752
  demo.queue().launch(ssr_mode=False)