File size: 2,012 Bytes
5fb0891
 
 
1521e2b
d1d37ba
5fb0891
 
 
 
 
 
1521e2b
5fb0891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1521e2b
5fb0891
 
 
 
 
 
 
 
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
import streamlit as st
from functions import *

st.set_page_config(page_title="Interview Summarization", page_icon="πŸ“–")
st.sidebar.header("Summarization")

max_len= st.slider("Maximum length of the summarized text",min_value=70,max_value=200,step=10,value=100)
min_len= st.slider("Minimum length of the summarized text",min_value=20,max_value=200,step=10)

st.markdown("####")     
        
st.subheader("Summarized Interview with matched Entities")

if "earnings_passages" not in st.session_state:
    st.session_state["earnings_passages"] = ''

if st.session_state['earnings_passages']:
      
    with st.spinner("Summarizing and matching entities, this takes a few seconds..."):
        
        try:
            text_to_summarize = chunk_and_preprocess_text(st.session_state['earnings_passages'])
            print(text_to_summarize)
            summarized_text = summarize_text(text_to_summarize,max_len=max_len,min_len=min_len)
            
        
        except IndexError:
            try:
                
                text_to_summarize = chunk_and_preprocess_text(st.session_state['earnings_passages'])
                summarized_text = summarize_text(text_to_summarize,max_len=max_len,min_len=min_len)
                
    
            except IndexError:
                
                text_to_summarize = chunk_and_preprocess_text(st.session_state['earnings_passages'])
                summarized_text = summarize_text(text_to_summarize,max_len=max_len,min_len=min_len)
                        
        entity_match_html = highlight_entities(text_to_summarize,summarized_text)
        st.markdown("####")
        
        with st.expander(label='Summarized Interview',expanded=True): 
            st.write(entity_match_html, unsafe_allow_html=True)
        
        st.markdown("####")     
        
        summary_downloader(summarized_text)
            
else:
      st.write("No text to summarize detected, please ensure you have entered the YouTube URL on the Sentiment Analysis page")