feat: one-click gallery of curated DisfluencySpeech demo clips under the recorder
Browse files9 unmodified lines10111213141516744 unmodified lines76176276376476576676776876977077177277377477577677777877978078178278378478578678778859 unmodified lines8488498508288298308518528538548558568578588598608618628638648658668678688699 unmodified lines
import difflibimport htmlimport osimport re
import gradio as gr744 unmodified lines
HEADER_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_SPECS if os.path.exists(os.path.join(_EX_DIR, fn))]EXAMPLE_LABELS = [ label for fn, label in _EXAMPLE_SPECS if os.path.exists(os.path.join(_EX_DIR, fn))]
FOOTER_HTML = """<div class="fw-footer">59 unmodified lines label="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. # 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