import gradio as gr import core with gr.Blocks(css = "app.css") as iface: gr.Markdown(elem_id="logo" , value="![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA81BMVEX///8AAAD/cgBbW1v8//////3//v//cADf39/8/Pz9cgD44sdgYGD8/v///v7Ly8v6ZwDr6+uQkJDT09Pa2trn5+e7u7vGxsaMjIwvLy9wcHBnZ2f19fW0tLScnJwhISFEREQ6Ojqurq4kJCROTk5TU1OioqJ8fHzwcgAVFRX0aAD/agCEhIRsbGwrKyv1XgD9//XwjTb26Nb35cH36uDrx5v0wZXvXwDxhybxhzfxzanx2bTwbQDyfCDst3/79eHregDtpmL0683xm07yl1HtqnL0pWDstXf9+en016/uw5TvwI3qkEDus3722r/xypH0qWylGcwEAAAL1ElEQVR4nO2bC3fTuBLHnVSyarVJ3fRBKX3xaAhJARe23VICaenSbaHs7vf/NFeSZethSZb33t29Z8/8OIcDiWxrNNLMXyMnSQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP6lYMY/3Ye/lqaFw7TL9Z0a/xMMBzjVLUQFToI+HWKMeDvxHzE6/+dzIC3Qu/crGgUzOXQBShFWV/yESvuyv6e3Sba+ubG2ud7pcRifvc0Vb89R2CcIoY/1BT//NihbH2x07OqTvY4XJOv7Oy96NUcn++uRF+K0mFBKSvqUTooUhdoPcXFB+0Rc0f+QFOUs7S116+5Wb9St/cHjXoPD0XLMtQOUfMtpn/YFhORnCPmnKcYpusyZbX02GHT6Ua7H/V5vs1OPd3u92JnG2j160TSv5Ol2+w3QEBVz5pTKQvohlD7Yd8WEUN6eEvoJpeWifdrr5sR11rmD2MaPDn32Cfbbrk9xkXye0dqHNP8YiI7sm/MpFRYSMjuTg7HGn9TFiS/5BXFNt46C9jHetMQAlhzwYkqVD8kpyxg+EzFazJn3CJ+k5IotWdFwiT/oON7APdGzcUzTgzb7OC/b7pIl1zM+60ob6fQ9xkNnt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YW1kB6+T/2Z6SthGuFipfqz3ZKkmTgDuH9cXRJbntSuc4X95ezx6+frJ7uhgf/N/9qvVtJouxh3/mh/F/g2PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADGfwC59LpOptX/lAAAAABJRU5ErkJggg==)") with gr.Row(): with gr.Tab("Upload Audio as File"): audio_input_u = gr.Audio(label = 'Upload Audio',source="upload",type="filepath") transcribe_audio_u = gr.Button('Transcribe') with gr.Tab("Record Audio"): audio_input_r = gr.Audio(label = 'Record Audio Input',source="microphone", type="filepath") transcribe_audio_r = gr.Button('Transcribe') with gr.Tab("Summarize Video from URL"): with gr.Row(): with gr.Column(elem_id="video_elem"): url_input = gr.Textbox(label="URL", elem_id="url_input") video = gr.Video(show_label=False, interactive = False) video.style(width=600) transcribe_url = gr.Button('Transcribe') with gr.Row(equal_height=True): with gr.Column(scale=2): asr_out_text = gr.Textbox(label="Transcript", lines=2, max_lines=20) asr_out_lang = gr.Dropdown(["English", "Vietnamese"], label="Language") with gr.Column(scale=1): asr_out_text_detail = gr.Textbox(label="Detail", lines=6, max_lines=24) with gr.Column(): summarize_btn = gr.Button("Summarize") summarize_out = gr.Textbox(label="Summarization") transcribe_audio_u.click(core.asr_transcript, audio_input_u, [asr_out_text, asr_out_lang, asr_out_text_detail]) transcribe_audio_r.click(core.asr_transcript, audio_input_r, [asr_out_text, asr_out_lang, asr_out_text_detail]) # audio_input_r.stream(core.asr_transcript, audio_input_r, [asr_out_text, asr_out_lang, asr_out_text_detail]) url_input.submit(core.load_video_url, [url_input], video) url_input.change(core.load_video_url, [url_input], video) transcribe_url.click(core.asr_transcript, video, [asr_out_text, asr_out_lang, asr_out_text_detail]) summarize_btn.click(core.text_summarize, [asr_out_text, asr_out_lang], summarize_out) examples = gr.Examples(examples=["Doc Truyen Dem Khuya.mp3", "The Diver An Uncanny Tale.mp3"], inputs=[audio_input_u]) examples = gr.Examples(examples=["https://www.youtube.com/watch?v=ADi7F695d90"], inputs=[url_input]) iface.launch(debug=True)