Spaces:
Sleeping
Sleeping
Used hugging face hub instead of torch and other modules to use the inference, instead of installing modules
Browse files- app.py +6 -8
- requirements.txt +0 -3
app.py
CHANGED
|
@@ -1,16 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 6 |
|
| 7 |
|
| 8 |
def transcribe(audio):
|
| 9 |
if audio is None:
|
| 10 |
return "", ""
|
| 11 |
-
|
| 12 |
-
text
|
| 13 |
-
return text, ""
|
| 14 |
|
| 15 |
|
| 16 |
def summarize(text):
|
|
@@ -18,8 +16,8 @@ def summarize(text):
|
|
| 18 |
return "No text to summarize."
|
| 19 |
if len(text.split()) < 30:
|
| 20 |
return "Text is too short to summarize."
|
| 21 |
-
|
| 22 |
-
return
|
| 23 |
|
| 24 |
|
| 25 |
with gr.Blocks(title="Audio Transcription & Summary") as demo:
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
client = InferenceClient()
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def transcribe(audio):
|
| 8 |
if audio is None:
|
| 9 |
return "", ""
|
| 10 |
+
text = client.automatic_speech_recognition(audio, model="openai/whisper-base")
|
| 11 |
+
return text.text, ""
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
def summarize(text):
|
|
|
|
| 16 |
return "No text to summarize."
|
| 17 |
if len(text.split()) < 30:
|
| 18 |
return "Text is too short to summarize."
|
| 19 |
+
result = client.summarization(text, model="facebook/bart-large-cnn")
|
| 20 |
+
return result.summary_text
|
| 21 |
|
| 22 |
|
| 23 |
with gr.Blocks(title="Audio Transcription & Summary") as demo:
|
requirements.txt
CHANGED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
transformers
|
| 2 |
-
torch
|
| 3 |
-
gradio
|
|
|
|
|
|
|
|
|
|
|
|