Spaces:
Runtime error
Runtime error
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("<center><h1> π Transcription <span class='cursive-text'>Delight</span> </h1></center>") | |
with gr.Row(): | |
with gr.Column(): | |
with gr.Row(): | |
source = gr.Radio(label="Source type", choices=[ ("YouTube URL", "youtube"), ("Audio", "audio"), ("Video", "video")], value="youtube") | |
cleanup_options = gr.CheckboxGroup(label="Cleanup Transcript with LLM", choices=["Remove typos", "Separate into paragraphs"]) | |
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" | |
).success( | |
lambda : gr.Accordion(open=True), | |
None, | |
raw_accordion | |
).then( | |
transcribe.transcribe, | |
[download_audio], | |
[preliminary_transcript], | |
show_progress="minimal" | |
).success( | |
lambda : (gr.Accordion(open=False), gr.Accordion(open=True)), | |
None, | |
[raw_accordion, final_accordion] | |
).then( | |
clean.clean_transcript, | |
[download_audio, cleanup_options, llm_prompt, preliminary_transcript], | |
[final_transcript, download_md], | |
show_progress="minimal" | |
) | |
with gr.Column(): | |
with gr.Row(): | |
transcribe_btn = gr.Button("Transcribe π", variant="primary") | |
with gr.Accordion("Raw transcript", open=False) as raw_accordion: | |
preliminary_transcript = gr.Markdown("*Raw transcript will appear here*", show_label=False, height=400) | |
with gr.Accordion("Final transcript", open=False) as final_accordion: | |
final_transcript = gr.Markdown("*Final transcript will appear here*", height=400) | |
source.change(utils.transcribe_button, source, transcribe_btn) | |
with gr.Accordion("βοΈ Settings and Files", open=False) as settings_accordion: | |
with gr.Row(): | |
with gr.Column(): | |
llm_prompt = gr.Textbox(label="LLM Prompt", visible=False, lines=3) | |
cleanup_options.change( | |
utils.generate_prompt, | |
cleanup_options, | |
[llm_prompt, settings_accordion] | |
) | |
with gr.Row(): | |
download_audio = gr.DownloadButton("Download .mp3 File π₯", interactive=False) | |
download_md = gr.DownloadButton("Download .md π₯", interactive=False) | |
demo.launch() |