IProject-10 commited on
Commit
1fbb0da
Β·
verified Β·
1 Parent(s): 63c2d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,17 +1,19 @@
1
  import gradio as gr
2
- import whisper
3
  from transformers import pipeline
4
 
5
- # Load models
6
  print("Loading models...")
7
- whisper_model = whisper.load_model("base")
8
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
9
 
10
  def transcribe(audio_path):
11
  if audio_path is None:
12
  return "Please record some audio."
13
- result = whisper_model.transcribe(audio_path)
14
- return result["text"]
 
 
15
 
16
  def summarize(text):
17
  if not text.strip():
@@ -19,11 +21,12 @@ def summarize(text):
19
  summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
20
  return summary[0]['summary_text']
21
 
 
22
  with gr.Blocks() as app:
23
- gr.Markdown("## πŸŽ™οΈ Real-Time Transcription & Summarization Tool\nSpeak into your mic and generate a summary.")
24
 
25
  with gr.Row():
26
- audio_input = gr.Audio(type="filepath", label="🎧 Record or Upload Audio")
27
  transcription_output = gr.Textbox(label="πŸ“ Transcription", lines=6, interactive=False)
28
 
29
  transcribe_button = gr.Button("Transcribe")
 
1
  import gradio as gr
2
+ from faster_whisper import WhisperModel
3
  from transformers import pipeline
4
 
5
+ # Load Faster-Whisper and BART model
6
  print("Loading models...")
7
+ whisper_model = WhisperModel("base") # You can use "tiny" if it's still too heavy
8
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
9
 
10
  def transcribe(audio_path):
11
  if audio_path is None:
12
  return "Please record some audio."
13
+
14
+ segments, _ = whisper_model.transcribe(audio_path)
15
+ transcription = " ".join([segment.text for segment in segments])
16
+ return transcription
17
 
18
  def summarize(text):
19
  if not text.strip():
 
21
  summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
22
  return summary[0]['summary_text']
23
 
24
+ # Build Gradio UI
25
  with gr.Blocks() as app:
26
+ gr.Markdown("## πŸŽ™οΈ Real-Time Transcription & Summarization\nSpeak into your mic and generate a summary.")
27
 
28
  with gr.Row():
29
+ audio_input = gr.Audio(type="filepath", label="🎧 Record Audio (Max ~120 sec)")
30
  transcription_output = gr.Textbox(label="πŸ“ Transcription", lines=6, interactive=False)
31
 
32
  transcribe_button = gr.Button("Transcribe")