Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
ZennyKenny
commited on
Update app.py
Browse files
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 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
)
|
29 |
|
30 |
-
#
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|