Spaces:
Runtime error
Runtime error
Brass-monkey
commited on
Commit
·
db47d53
1
Parent(s):
ec1d9df
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from PyPDF2 import PdfReader
|
3 |
from transformers import pipeline
|
4 |
-
from bark import SAMPLE_RATE, generate_audio, preload_models
|
5 |
from IPython.display import Audio
|
6 |
|
7 |
# Preload Bark models
|
@@ -10,7 +10,7 @@ preload_models()
|
|
10 |
def summarize_generate_audio(files):
|
11 |
summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model")
|
12 |
summaries = []
|
13 |
-
audios = []
|
14 |
|
15 |
for file in files:
|
16 |
with open(file.name, "rb") as pdf_file:
|
@@ -20,16 +20,16 @@ def summarize_generate_audio(files):
|
|
20 |
text += page.extract_text() + "\n"
|
21 |
summary = summarizer(text, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
|
22 |
summaries.append(summary)
|
23 |
-
audio_array = generate_audio(summary)
|
24 |
-
audios.append(audio_array)
|
25 |
-
return summaries, audios
|
26 |
|
27 |
iface = gr.Interface(
|
28 |
fn=summarize_generate_audio,
|
29 |
inputs=gr.UploadButton("Click to Upload a PDF", file_types=["pdf"], file_count="multiple"),
|
30 |
outputs=[
|
31 |
gr.Textbox(label="Summarized Text"),
|
32 |
-
gr.Audio(label="Generated Audio")
|
33 |
],
|
34 |
title="PDF Summarizer & Audio Generator"
|
35 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from PyPDF2 import PdfReader
|
3 |
from transformers import pipeline
|
4 |
+
# from bark import SAMPLE_RATE, generate_audio, preload_models
|
5 |
from IPython.display import Audio
|
6 |
|
7 |
# Preload Bark models
|
|
|
10 |
def summarize_generate_audio(files):
|
11 |
summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model")
|
12 |
summaries = []
|
13 |
+
# audios = []
|
14 |
|
15 |
for file in files:
|
16 |
with open(file.name, "rb") as pdf_file:
|
|
|
20 |
text += page.extract_text() + "\n"
|
21 |
summary = summarizer(text, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
|
22 |
summaries.append(summary)
|
23 |
+
# audio_array = generate_audio(summary)
|
24 |
+
# audios.append(audio_array)
|
25 |
+
return summaries, #audios
|
26 |
|
27 |
iface = gr.Interface(
|
28 |
fn=summarize_generate_audio,
|
29 |
inputs=gr.UploadButton("Click to Upload a PDF", file_types=["pdf"], file_count="multiple"),
|
30 |
outputs=[
|
31 |
gr.Textbox(label="Summarized Text"),
|
32 |
+
# gr.Audio(label="Generated Audio")
|
33 |
],
|
34 |
title="PDF Summarizer & Audio Generator"
|
35 |
)
|