File size: 2,969 Bytes
8cd194c
fd90156
 
407cc22
d8a7b6b
88322f7
add165b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88322f7
add165b
 
 
88322f7
add165b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8a7b6b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import gradio as gr
import utils
import transcribe

with gr.Blocks(theme="base") as demo:
    gr.Markdown("<center><h1> πŸ”Š Transcription Delight </h1></center>")
    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(
                #     lambda : gr.Tabs(selected="result"),
                #     None,
                #     tabs
                # ).then(
                #     utils.generate_audio,
                #     [source, source_component],
                #     [download_audio],
                #     show_progress="minimal"
                # ).then(
                #     transcribe.transcribe,
                #     [download_audio],
                #     [preliminary_transcript],
                #     show_progress="hidden"
                # )

        with gr.Column():
            transcribe_btn = gr.Button("Transcribe audio πŸ“œ", variant="primary")
            preliminary_transcript = gr.Textbox(info="Raw transcript", 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.Column():
            clean_btn = gr.Button("Clean transcript ✨", variant="primary", interactive=False)
            gr.Markdown("*Final transcript will appear here*")
        # with gr.Tab("Result", id="result"):
        #     with gr.Row():
        #         with gr.Column():
        #             download_audio = gr.DownloadButton("Downloading Audio File (please wait...)", variant="primary", interactive=False, size="sm")
        #             preliminary_transcript = gr.Textbox(info="Raw transcript", lines=10, show_copy_button=True, show_label=False, interactive=False)
        #         with gr.Column():
    
demo.launch()