feat: one-click gallery of curated DisfluencySpeech demo clips under the recorder
Browse files9 unmodified lines101112131415744 unmodified lines76076176276376476559 unmodified lines8258268278288298308318328338348359 unmodified linesimport difflibimport htmlimport reimport gradio as gr744 unmodified linesHEADER_HTML = _build_header_html(FACTS)FOOTER_HTML = """<div class="fw-footer">59 unmodified lineslabel="Speak or upload audio",elem_classes=["fw-audio"],# The mid-recording "page unresponsive" freeze came from the cold# model load blocking the first request. We now preload the model at# startup on Spaces (see top of file), so that is no longer an issue# and the live recording waveform is safe to keep on.waveform_options=gr.WaveformOptions(show_recording_waveform=True),)run_btn = gr.Button("Transcribe", variant="primary", elem_classes=["fw-btn"])9 unmodified lines10111213141516744 unmodified lines76176276376476576676776876977077177277377477577677777877978078178278378478578678778859 unmodified lines8488498508518528538548558568578588598608618628638648658668678688699 unmodified linesimport difflibimport htmlimport osimport reimport gradio as gr744 unmodified linesHEADER_HTML = _build_header_html(FACTS)# ---------------------------------------------------------------------------# Curated example clips (real DisfluencySpeech test audio). Each entry is only# offered if its .wav is actually present, so a missing file never breaks the# build. Paths are resolved next to this file so they work locally and on Space.# ---------------------------------------------------------------------------_EX_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "examples")_EXAMPLE_SPECS = [("idx_049.wav", 'Removes "you know" and "I mean"'),("idx_144.wav", 'Removes "Oh", "Well", and "like"'),("idx_222.wav", 'Removes "you know" twice'),("idx_083.wav", 'Removes "really, you know"'),("idx_158.wav", 'Trims a stuttered repetition'),]EXAMPLES = [[os.path.join(_EX_DIR, fn)] for fn, _ in _EXAMPLE_SPECSif os.path.exists(os.path.join(_EX_DIR, fn))]EXAMPLE_LABELS = [label for fn, label in _EXAMPLE_SPECSif os.path.exists(os.path.join(_EX_DIR, fn))]FOOTER_HTML = """<div class="fw-footer">59 unmodified lineslabel="Speak or upload audio",elem_classes=["fw-audio"],# The mid-recording "page unresponsive" freeze came from the cold# model load blocking the first request, which the lazy load inside# the @spaces.GPU transcribe function keeps off the page thread.waveform_options=gr.WaveformOptions(show_recording_waveform=True),)# Curated DisfluencySpeech test clips where the adapter cleanly removes# real discourse markers and repetitions. These are the examples behind# the 3.4% WER number, so they show the model at its best for the demo.if EXAMPLES:gr.Examples(examples=EXAMPLES,inputs=audio_in,label="Or try a real clip from the DisfluencySpeech test set",example_labels=EXAMPLE_LABELS,)run_btn = gr.Button("Transcribe", variant="primary", elem_classes=["fw-btn"])
app.py+37-3