Spaces:
Runtime error
Runtime error
citizendeeplearner
commited on
Commit
•
10f50b1
1
Parent(s):
b34c4a4
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Thu Sep 8 20:02:01 2022
|
4 |
+
|
5 |
+
@author: User
|
6 |
+
"""
|
7 |
+
|
8 |
+
import streamlit as st
|
9 |
+
from selenium import webdriver
|
10 |
+
from selenium.webdriver.chrome.service import Service
|
11 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
12 |
+
from bs4 import BeautifulSoup
|
13 |
+
from selenium.webdriver.chrome.options import Options
|
14 |
+
|
15 |
+
from transformers import pipeline
|
16 |
+
|
17 |
+
|
18 |
+
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
|
19 |
+
|
20 |
+
st.title('Music Lyrics Summarizer')
|
21 |
+
st.subheader('A Summary of the lyrics of your favourite English songs, prepared by AI')
|
22 |
+
def get_lyrics(inp):
|
23 |
+
|
24 |
+
lyrics_text=[]
|
25 |
+
strung_together=''.join(inp.split(' '))
|
26 |
+
initial="https://www.google.com/search?q="
|
27 |
+
str_=f"{initial}{strung_together}+lyrics&oq="
|
28 |
+
|
29 |
+
driver.get(str_)
|
30 |
+
src = driver.page_source
|
31 |
+
soup = BeautifulSoup(src, 'lxml')
|
32 |
+
|
33 |
+
lyrics_soup = soup.find_all('div', {'class': 'ujudUb'})
|
34 |
+
for span_tags in lyrics_soup:
|
35 |
+
span_content=soup.find_all('span', {'jsname': 'YS01Ge'})
|
36 |
+
for embedded_lyrics in span_content:
|
37 |
+
lyrics_text.append(embedded_lyrics.get_text())
|
38 |
+
return lyrics_text
|
39 |
+
|
40 |
+
inp=st.text_input(label='Insert song name and artist name:')
|
41 |
+
st.caption('Please wait while the AI tries to read the lyrics of your song from Google and understand it.')
|
42 |
+
|
43 |
+
lyrics=get_lyrics(inp)
|
44 |
+
transcript=''
|
45 |
+
for i in lyrics:
|
46 |
+
transcript+=i+'.'+' '
|
47 |
+
summarizer = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM")
|
48 |
+
|
49 |
+
def summarize(lyrics):
|
50 |
+
try:
|
51 |
+
summed=summarizer(transcript[:len(transcript)],max_length=200,min_length=100)
|
52 |
+
except IndexError:
|
53 |
+
summed=summarizer(transcript[:3000],max_length=200,min_length=100)
|
54 |
+
|
55 |
+
return summed[0]['summary_text']
|
56 |
+
|
57 |
+
summary=summarize(transcript[:len(transcript)-10])
|
58 |
+
#print(summary)
|
59 |
+
st.caption("<-> You have a cool music taste. But what's cooler is my ability to understand music <->")
|
60 |
+
st.write(summary)
|
61 |
+
|
62 |
+
st.stop()
|
63 |
+
|