|
import gradio as gr |
|
import core |
|
|
|
with gr.Blocks(css = "app.css") as iface: |
|
gr.Markdown(elem_id="logo" , value="") |
|
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]) |
|
|
|
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) |