Walid-Ahmed commited on
Commit
51dfe6b
·
verified ·
1 Parent(s): c9ccf46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -6,15 +6,24 @@ import gradio as gr
6
  device = "cpu"
7
  print("Running on CPU")
8
 
9
- # Load the Whisper model on CPU
10
- model_name = "tiny" # Change to "base", "small", etc., as needed
11
- whisper_model = whisper.load_model("tiny")
12
-
13
- # Define the transcription function
14
- def transcribe(audio):
15
- # Perform transcription using the Whisper model
16
- result = whisper_model.transcribe(audio)
17
- return result["text"]
 
 
 
 
 
 
 
 
 
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(