Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,24 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
import gradio as gr
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
os.environ["HF_HUB_DOWNLOAD_TIMEOUT"] = "300"
|
| 7 |
+
|
| 8 |
+
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-tiny.en", chunk_length_s=30)
|
| 9 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 10 |
+
|
| 11 |
+
def transcript_and_summarize(audio_file):
|
| 12 |
+
transcript = asr_pipe(audio_file)["text"]
|
| 13 |
+
summary = summarizer(transcript, max_length=100, min_length=30, do_sample=False)[0]["summary_text"]
|
| 14 |
+
return f"**Transcription:**\n{transcript}\n\n**Summary (Notes):**\n{summary}"
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=transcript_and_summarize,
|
| 18 |
+
inputs=gr.Audio(sources=["upload"], type="filepath"),
|
| 19 |
+
outputs=gr.Textbox(),
|
| 20 |
+
title="Audio Transcription & Note-Making",
|
| 21 |
+
description="Upload an audio file to transcribe and get summarized notes."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
iface.launch()
|