|
|
|
import whisper |
|
import gradio as gr |
|
|
|
|
|
from transformers import pipeline |
|
|
|
|
|
device = "cpu" |
|
print("Running on CPU") |
|
|
|
|
|
|
|
model = whisper.load_model("base") |
|
|
|
|
|
summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn") |
|
|
|
|
|
def transcribe_and_summarize(audio): |
|
|
|
transcription_result = whisper_model.transcribe(audio) |
|
transcription = transcription_result['text'] |
|
|
|
|
|
summary = summarizer(transcription, min_length=10, max_length=100) |
|
summary_text = summary[0]['summary_text'] |
|
|
|
return transcription, summary_text |
|
|
|
|
|
demo = gr.Interface( |
|
fn=transcribe, |
|
inputs=gr.Audio(type="filepath", label="Upload your audio file"), |
|
outputs=gr.Textbox(label="Transcription"), |
|
title="Whisper Speech-to-Text", |
|
description="Record audio using your microphone and get a transcription using the Whisper model." |
|
) |
|
|
|
|
|
demo.launch() |
|
|
|
|