import gradio as gr import utils import clean import transcribe css = """ .cursive-text { font-family: 'Brush Script MT', cursive; } """ with gr.Blocks(theme="base", css=css) as demo: gr.Markdown("

🔊 Transcription Delight

") gr.Markdown("### Step 1: Generate Raw Transcript") with gr.Row(): with gr.Column(): source = gr.Radio(label="Source type", choices=[("Audio", "audio"), ("Video", "video"), ("YouTube URL", "youtube")], value="audio") @gr.render(inputs=source) def show_source(s): if s == "audio": source_component = gr.Audio(type="filepath") elif s == "video": source_component = gr.Video() else: source_component = gr.Textbox(placeholder="https://www.youtube.com/watch?v=44vi31hehw4") preview = gr.HTML(label="Video preview") source_component.change(utils.convert_to_embed_url, source_component, preview) transcribe_btn.click( utils.generate_audio, [source, source_component], [download_audio], show_progress="minimal" ).then( transcribe.transcribe, [download_audio], [preliminary_transcript], ).then( lambda : [gr.Button(interactive=True), gr.CheckboxGroup(interactive=True)], None, [clean_btn, cleanup_options] ) with gr.Column(): with gr.Row(): transcribe_btn = gr.Button("Transcribe audio 📜", variant="primary") download_audio = gr.DownloadButton("Download .mp3 File 📥", interactive=False) preliminary_transcript = gr.Textbox(info="Raw transcript", lines=10, max_lines=10, show_copy_button=True, show_label=False, interactive=False) source.change(utils.transcribe_button, source, transcribe_btn) gr.Markdown("### Step 2: Clean with an LLM") with gr.Row(): with gr.Column(): cleanup_options = gr.CheckboxGroup(label="Cleanup Transcript with LLM", choices=["Remove typos", "Separate into paragraphs"]) llm_prompt = gr.Textbox(label="LLM Prompt", visible=False, lines=3) cleanup_options.change( utils.generate_prompt, cleanup_options, llm_prompt ) with gr.Row(): clean_btn = gr.Button("Clean transcript ✨", variant="primary") download_md = gr.DownloadButton("Download .md 📥", interactive=False) with gr.Column(): final_transcript = gr.Markdown("*Final transcript will appear here*", height=400) clean_btn.click( clean.clean_transcript, [download_audio, cleanup_options, llm_prompt, preliminary_transcript], [final_transcript, download_md], show_progress="minimal" ) demo.launch()