ZennyKenny commited on
Commit
6befe57
·
verified ·
1 Parent(s): 321b2ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -14
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  from transformers import pipeline
3
 
4
  # Load models
5
- transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base")
6
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
7
 
8
  # Function to process audio
@@ -15,17 +15,24 @@ def process_audio(audio_file):
15
 
16
  return transcription, summary
17
 
18
- # Gradio Interface
19
- interface = gr.Interface(
20
- fn=process_audio,
21
- inputs=gr.Audio(type="filepath", label="Upload Audio File"),
22
- outputs=[
23
- gr.Textbox(label="Full Transcription"),
24
- gr.Textbox(label="Summary")
25
- ],
26
- title="Audio Transcription and Summarization",
27
- description="Upload an audio file to get a full transcription and a brief summary of its content."
28
- )
29
 
30
- # Launch the interface
31
- interface.launch()
 
 
 
 
 
 
 
 
2
  from transformers import pipeline
3
 
4
  # Load models
5
+ transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0 if torch.cuda.is_available() else -1)
6
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
7
 
8
  # Function to process audio
 
15
 
16
  return transcription, summary
17
 
18
+ # Gradio Interface with Horizontal Layout
19
+ with gr.Blocks() as interface:
20
+ with gr.Row():
21
+ # Upload button on the left
22
+ with gr.Column():
23
+ audio_input = gr.Audio(type="filepath", label="Upload Audio File")
24
+ process_button = gr.Button("Process Audio")
25
+ # Output text box on the right
26
+ with gr.Column():
27
+ transcription_output = gr.Textbox(label="Full Transcription", lines=10)
28
+ summary_output = gr.Textbox(label="Summary", lines=5)
29
 
30
+ # Link the button to the function
31
+ process_button.click(
32
+ process_audio,
33
+ inputs=[audio_input],
34
+ outputs=[transcription_output, summary_output]
35
+ )
36
+
37
+ # Launch the interface with SSR disabled and optional public sharing
38
+ interface.launch