File size: 1,303 Bytes
a2a46d0
ee9acb0
a2a46d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37



import gradio as gr
import whisper
from transformers import pipeline

# Load the tiny Whisper model
whisper_model = whisper.load_model("tiny")
model = whisper.load_model("base")

# Load the text summarization model from Hugging Face
summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")

# Function to transcribe and summarize the audio file
def transcribe_and_summarize(audio):
    # Step 1: Transcribe the audio using Whisper
    transcription_result = whisper_model.transcribe(audio)
    transcription = transcription_result['text']

    # Step 2: Summarize the transcription
    summary = summarizer(transcription, min_length=10, max_length=100)
    summary_text = summary[0]['summary_text']

    return transcription, summary_text

# Define the Gradio interface
interface = gr.Interface(
    fn=transcribe_and_summarize,  # Function to run
    inputs=gr.Audio(type="filepath", label="Upload your audio file"),  # Input audio field
    outputs=[gr.Textbox(label="Transcription"), gr.Textbox(label="Summary")],  # Output fields
    title="Whisper Tiny Transcription and Summarization",
    description="Upload an audio file, get the transcription from Whisper tiny model and the summarized version using Hugging Face."
)

# Launch the Gradio app
interface.launch(debug=True)