Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,15 +6,24 @@ import gradio as gr
|
|
6 |
device = "cpu"
|
7 |
print("Running on CPU")
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Create the Gradio interface
|
20 |
demo = gr.Interface(
|
|
|
6 |
device = "cpu"
|
7 |
print("Running on CPU")
|
8 |
|
9 |
+
|
10 |
+
# Load the tiny Whisper model
|
11 |
+
model = whisper.load_model("base")
|
12 |
+
|
13 |
+
# Load the text summarization model from Hugging Face
|
14 |
+
summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")
|
15 |
+
|
16 |
+
# Function to transcribe and summarize the audio file
|
17 |
+
def transcribe_and_summarize(audio):
|
18 |
+
# Step 1: Transcribe the audio using Whisper
|
19 |
+
transcription_result = whisper_model.transcribe(audio)
|
20 |
+
transcription = transcription_result['text']
|
21 |
+
|
22 |
+
# Step 2: Summarize the transcription
|
23 |
+
summary = summarizer(transcription, min_length=10, max_length=100)
|
24 |
+
summary_text = summary[0]['summary_text']
|
25 |
+
|
26 |
+
return transcription, summary_text
|
27 |
|
28 |
# Create the Gradio interface
|
29 |
demo = gr.Interface(
|