Spaces:
Runtime error
Runtime error
first commit
Browse files- .DS_Store +0 -0
- app.py +38 -0
- requirement.txt +3 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
from gtts import gTTS
|
4 |
+
|
5 |
+
def audio(text):
|
6 |
+
# Summarize the input text using the Hugging Face model
|
7 |
+
# Load the pre-trained summarization model from Hugging Face
|
8 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
9 |
+
summary = summarizer(text, do_sample=False)[0]["summary_text"]
|
10 |
+
# Convert the summary to audio using Google Text-to-Speech
|
11 |
+
tts = gTTS(summary)
|
12 |
+
tts.save("summary.mp3")
|
13 |
+
return "summary.mp3"
|
14 |
+
|
15 |
+
def text_summary(text):
|
16 |
+
# Summarize the input text using the Hugging Face model
|
17 |
+
# Load the pre-trained summarization model from Hugging Face
|
18 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
19 |
+
summary = summarizer(text, do_sample=False)[0]["summary_text"]
|
20 |
+
return summary
|
21 |
+
|
22 |
+
# using streamlit to create a web app to display the summary or play the audio
|
23 |
+
|
24 |
+
import streamlit as st
|
25 |
+
|
26 |
+
st.title("📌 Your Personal Audio Summary")
|
27 |
+
text = st.text_input("Enter text to summarize")
|
28 |
+
|
29 |
+
#choose between text summary or audio summary
|
30 |
+
option = st.selectbox("Choose between text summary or audio summary", ("📃Text Summary", "🗣Audio Summary"))
|
31 |
+
|
32 |
+
if st.button("Summarize"):
|
33 |
+
if option == "📃Text Summary":
|
34 |
+
summary = text_summary(text)
|
35 |
+
st.write(summary)
|
36 |
+
if option == "🗣Audio Summary":
|
37 |
+
file_path = audio(text)
|
38 |
+
st.audio(file_path)
|
requirement.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|
3 |
+
gtts
|