File size: 2,650 Bytes
a83992e
 
 
10f50b1
a83992e
 
10f50b1
 
 
 
 
 
 
 
 
29c2ae8
 
 
 
10f50b1
29c2ae8
10f50b1
29c2ae8
 
 
 
 
 
 
 
 
 
10f50b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  8 20:02:01 2022

@author: User
"""

import streamlit as st
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options

from transformers import pipeline
chromeOptions = webdriver.ChromeOptions() 
chromeOptions.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2}) 
chromeOptions.add_argument("--no-sandbox") 
chromeOptions.add_argument("--disable-setuid-sandbox") 

chromeOptions.add_argument("--remote-debugging-port=9222")  # this

chromeOptions.add_argument("--disable-dev-shm-using") 
chromeOptions.add_argument("--disable-extensions") 
chromeOptions.add_argument("--disable-gpu") 
chromeOptions.add_argument("start-maximized") 
chromeOptions.add_argument("disable-infobars")
chromeOptions.add_argument(r"user-data-dir=.\cookies\\test") 

driver = webdriver.Chrome(chrome_options=chromeOptions)

#driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

st.title('Music Lyrics Summarizer')
st.subheader('A Summary of the lyrics of your favourite English songs, prepared by AI')
def get_lyrics(inp):
    
    lyrics_text=[]
    strung_together=''.join(inp.split(' '))
    initial="https://www.google.com/search?q="
    str_=f"{initial}{strung_together}+lyrics&oq="
    
    driver.get(str_) 
    src = driver.page_source
    soup = BeautifulSoup(src, 'lxml')
    
    lyrics_soup = soup.find_all('div', {'class': 'ujudUb'})
    for span_tags in lyrics_soup:
        span_content=soup.find_all('span', {'jsname': 'YS01Ge'})
        for embedded_lyrics in span_content:
            lyrics_text.append(embedded_lyrics.get_text())
    return lyrics_text

inp=st.text_input(label='Insert song name and artist name:')
st.caption('Please wait while the AI tries to read the lyrics of your song from Google and understand it.')

lyrics=get_lyrics(inp) 
transcript=''
for i in lyrics:
    transcript+=i+'.'+' '
summarizer = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM") 

def summarize(lyrics):
    try:
        summed=summarizer(transcript[:len(transcript)],max_length=200,min_length=100)
    except IndexError:
        summed=summarizer(transcript[:3000],max_length=200,min_length=100)
        
    return summed[0]['summary_text']

summary=summarize(transcript[:len(transcript)-10])
#print(summary)
st.caption("<->  You have a cool music taste. But what's cooler is my ability to understand music  <->")
st.write(summary)

st.stop()