ZennyKenny commited on
Commit
b40af2a
·
verified ·
1 Parent(s): 24c7355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,7 +1,31 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  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
9
+ def process_audio(audio_file):
10
+ # Step 1: Transcribe audio
11
+ transcription = transcriber(audio_file)["text"]
12
+
13
+ # Step 2: Summarize transcription
14
+ summary = summarizer(transcription, max_length=50, min_length=10, do_sample=False)[0]["summary_text"]
15
+
16
+ return transcription, summary
17
+
18
+ # Gradio Interface
19
+ interface = gr.Interface(
20
+ fn=process_audio,
21
+ inputs=gr.Audio(source="upload", 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()