pradachan commited on
Commit
d07a48e
·
verified ·
1 Parent(s): 57861f1

feat: one-click gallery of curated DisfluencySpeech demo clips under the recorder

Browse files
Files changed (1) hide show
  1. app.py +37 -3
app.py CHANGED
@@ -10,6 +10,7 @@ delete um/uh" (vanilla already does that natively).
10
 
11
  import difflib
12
  import html
 
13
  import re
14
 
15
  import gradio as gr
@@ -760,6 +761,28 @@ footer { display: none !important; }
760
 
761
  HEADER_HTML = _build_header_html(FACTS)
762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
 
764
  FOOTER_HTML = """
765
  <div class="fw-footer">
@@ -825,11 +848,22 @@ def build_demo():
825
  label="Speak or upload audio",
826
  elem_classes=["fw-audio"],
827
  # The mid-recording "page unresponsive" freeze came from the cold
828
- # model load blocking the first request. We now preload the model at
829
- # startup on Spaces (see top of file), so that is no longer an issue
830
- # and the live recording waveform is safe to keep on.
831
  waveform_options=gr.WaveformOptions(show_recording_waveform=True),
832
  )
 
 
 
 
 
 
 
 
 
 
 
 
833
  run_btn = gr.Button(
834
  "Transcribe", variant="primary", elem_classes=["fw-btn"]
835
  )
 
10
 
11
  import difflib
12
  import html
13
+ import os
14
  import re
15
 
16
  import gradio as gr
 
761
 
762
  HEADER_HTML = _build_header_html(FACTS)
763
 
764
+ # ---------------------------------------------------------------------------
765
+ # Curated example clips (real DisfluencySpeech test audio). Each entry is only
766
+ # offered if its .wav is actually present, so a missing file never breaks the
767
+ # build. Paths are resolved next to this file so they work locally and on Space.
768
+ # ---------------------------------------------------------------------------
769
+ _EX_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "examples")
770
+ _EXAMPLE_SPECS = [
771
+ ("idx_049.wav", 'Removes "you know" and "I mean"'),
772
+ ("idx_144.wav", 'Removes "Oh", "Well", and "like"'),
773
+ ("idx_222.wav", 'Removes "you know" twice'),
774
+ ("idx_083.wav", 'Removes "really, you know"'),
775
+ ("idx_158.wav", 'Trims a stuttered repetition'),
776
+ ]
777
+ EXAMPLES = [
778
+ [os.path.join(_EX_DIR, fn)] for fn, _ in _EXAMPLE_SPECS
779
+ if os.path.exists(os.path.join(_EX_DIR, fn))
780
+ ]
781
+ EXAMPLE_LABELS = [
782
+ label for fn, label in _EXAMPLE_SPECS
783
+ if os.path.exists(os.path.join(_EX_DIR, fn))
784
+ ]
785
+
786
 
787
  FOOTER_HTML = """
788
  <div class="fw-footer">
 
848
  label="Speak or upload audio",
849
  elem_classes=["fw-audio"],
850
  # The mid-recording "page unresponsive" freeze came from the cold
851
+ # model load blocking the first request, which the lazy load inside
852
+ # the @spaces.GPU transcribe function keeps off the page thread.
 
853
  waveform_options=gr.WaveformOptions(show_recording_waveform=True),
854
  )
855
+
856
+ # Curated DisfluencySpeech test clips where the adapter cleanly removes
857
+ # real discourse markers and repetitions. These are the examples behind
858
+ # the 3.4% WER number, so they show the model at its best for the demo.
859
+ if EXAMPLES:
860
+ gr.Examples(
861
+ examples=EXAMPLES,
862
+ inputs=audio_in,
863
+ label="Or try a real clip from the DisfluencySpeech test set",
864
+ example_labels=EXAMPLE_LABELS,
865
+ )
866
+
867
  run_btn = gr.Button(
868
  "Transcribe", variant="primary", elem_classes=["fw-btn"]
869
  )