alyxsis commited on
Commit
800a2c4
·
verified ·
1 Parent(s): 7a353a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -112
app.py CHANGED
@@ -491,122 +491,102 @@ def transcribe_youtube(
491
 
492
  # Build the Gradio interface
493
  with gr.Blocks(title="Parakeet-ASR") as demo:
494
- # Header
495
- gr.HTML(
496
- f"""
497
- <h1 style='text-align: center;'>Parakeet-ASR 🦜</h1>
498
- <p style='text-align: center;'>
499
- Powered by <code>nvidia/parakeet-tdt-0.6b-v3</code> on
500
- <strong>{get_device_info().upper()}</strong>
501
- </p>
502
- <p style='text-align: center; font-size: 0.9em;'>
503
- Supports 25 European languages with automatic detection, punctuation, and capitalization.
504
- </p>
505
- """
506
- )
507
 
508
- with gr.Tabs():
509
- # Tab 1: Audio File / Microphone
510
- with gr.TabItem("Audio File"):
511
- with gr.Row():
512
- with gr.Column():
513
- audio_input = gr.Audio(
514
- label="Audio Input",
515
- sources=["microphone", "upload"],
516
- type="filepath",
517
- )
518
-
519
- timestamps_checkbox = gr.Checkbox(
520
- label="Return Timestamps",
521
- value=False,
522
- )
523
-
524
- timestamp_level_radio = gr.Radio(
525
- choices=["segment", "word", "char"],
526
- value="segment",
527
- label="Timestamp Level",
528
- info="Level of detail for timestamps",
529
- visible=False,
530
- )
531
-
532
- # Show/hide timestamp level based on checkbox
533
- timestamps_checkbox.change(
534
- fn=lambda x: gr.Radio(visible=x),
535
- inputs=[timestamps_checkbox],
536
- outputs=[timestamp_level_radio],
537
- )
538
-
539
- transcribe_btn = gr.Button("Transcribe", variant="primary")
540
-
541
- with gr.Column():
542
- audio_output = gr.Textbox(
543
- label="Transcription",
544
- placeholder="Transcribed text will appear here...",
545
- lines=12,
546
- )
547
-
548
- with gr.Row():
549
- download_csv_btn = gr.DownloadButton(
550
- label="Download CSV",
551
- visible=False,
552
- )
553
- download_srt_btn = gr.DownloadButton(
554
- label="Download SRT",
555
- visible=False,
556
- )
557
-
558
- transcribe_btn.click(
559
- fn=transcribe_audio,
560
- inputs=[audio_input, timestamps_checkbox, timestamp_level_radio],
561
- outputs=[audio_output, download_csv_btn, download_srt_btn],
562
- api_name="transcribe",
563
  )
564
 
565
- # Tab 2: YouTube (only shown when running locally)
566
- if not IS_HF_SPACE:
567
- with gr.TabItem("YouTube"):
568
- with gr.Row():
569
- with gr.Column():
570
- yt_url_input = gr.Textbox(
571
- label="YouTube URL",
572
- placeholder="Paste a YouTube video URL here...",
573
- lines=1,
574
- )
575
-
576
- yt_timestamps_checkbox = gr.Checkbox(
577
- label="Return Timestamps",
578
- value=False,
579
- )
580
-
581
- yt_timestamp_level_radio = gr.Radio(
582
- choices=["segment", "word"],
583
- value="segment",
584
- label="Timestamp Level",
585
- visible=False,
586
- )
587
-
588
- yt_timestamps_checkbox.change(
589
- fn=lambda x: gr.Radio(visible=x),
590
- inputs=[yt_timestamps_checkbox],
591
- outputs=[yt_timestamp_level_radio],
592
- )
593
-
594
- yt_transcribe_btn = gr.Button("Transcribe YouTube", variant="primary")
595
-
596
- with gr.Column():
597
- yt_embed = gr.HTML(label="Video")
598
- yt_output = gr.Textbox(
599
- label="Transcription",
600
- placeholder="Transcribed text will appear here...",
601
- lines=10,
602
- )
603
-
604
- yt_transcribe_btn.click(
605
- fn=transcribe_youtube,
606
- inputs=[yt_url_input, yt_timestamps_checkbox, yt_timestamp_level_radio],
607
- outputs=[yt_embed, yt_output],
608
- api_name="transcribe_youtube",
609
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
 
611
 
612
 
 
491
 
492
  # Build the Gradio interface
493
  with gr.Blocks(title="Parakeet-ASR") as demo:
494
+ with gr.Row():
495
+ with gr.Column():
496
+ audio_input = gr.Audio(
497
+ label="Audio Input",
498
+ sources=["microphone", "upload"],
499
+ type="filepath",
500
+ )
 
 
 
 
 
 
501
 
502
+ timestamps_checkbox = gr.Checkbox(
503
+ label="Return Timestamps",
504
+ value=False,
505
+ )
506
+
507
+ timestamp_level_radio = gr.Radio(
508
+ choices=["segment", "word", "char"],
509
+ value="segment",
510
+ label="Timestamp Level",
511
+ info="Level of detail for timestamps",
512
+ visible=False,
513
+ )
514
+
515
+ timestamps_checkbox.change(
516
+ fn=lambda x: gr.Radio(visible=x),
517
+ inputs=[timestamps_checkbox],
518
+ outputs=[timestamp_level_radio],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  )
520
 
521
+ transcribe_btn = gr.Button("Transcribe", variant="primary")
522
+
523
+ with gr.Column():
524
+ audio_output = gr.Textbox(
525
+ label="Transcription",
526
+ placeholder="Transcribed text will appear here...",
527
+ lines=12,
528
+ )
529
+
530
+ with gr.Row():
531
+ download_csv_btn = gr.DownloadButton(
532
+ label="Download CSV",
533
+ visible=False,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  )
535
+ download_srt_btn = gr.DownloadButton(
536
+ label="Download SRT",
537
+ visible=False,
538
+ )
539
+
540
+ transcribe_btn.click(
541
+ fn=transcribe_audio,
542
+ inputs=[audio_input, timestamps_checkbox, timestamp_level_radio],
543
+ outputs=[audio_output, download_csv_btn, download_srt_btn],
544
+ api_name="transcribe",
545
+ )
546
+
547
+ if not IS_HF_SPACE:
548
+ with gr.Row():
549
+ with gr.Column():
550
+ yt_url_input = gr.Textbox(
551
+ label="YouTube URL",
552
+ placeholder="Paste a YouTube video URL here...",
553
+ lines=1,
554
+ )
555
+
556
+ yt_timestamps_checkbox = gr.Checkbox(
557
+ label="Return Timestamps",
558
+ value=False,
559
+ )
560
+
561
+ yt_timestamp_level_radio = gr.Radio(
562
+ choices=["segment", "word"],
563
+ value="segment",
564
+ label="Timestamp Level",
565
+ visible=False,
566
+ )
567
+
568
+ yt_timestamps_checkbox.change(
569
+ fn=lambda x: gr.Radio(visible=x),
570
+ inputs=[yt_timestamps_checkbox],
571
+ outputs=[yt_timestamp_level_radio],
572
+ )
573
+
574
+ yt_transcribe_btn = gr.Button("Transcribe YouTube", variant="primary")
575
+
576
+ with gr.Column():
577
+ yt_embed = gr.HTML(label="Video")
578
+ yt_output = gr.Textbox(
579
+ label="Transcription",
580
+ placeholder="Transcribed text will appear here...",
581
+ lines=10,
582
+ )
583
+
584
+ yt_transcribe_btn.click(
585
+ fn=transcribe_youtube,
586
+ inputs=[yt_url_input, yt_timestamps_checkbox, yt_timestamp_level_radio],
587
+ outputs=[yt_embed, yt_output],
588
+ api_name="transcribe_youtube",
589
+ )
590
 
591
 
592