Dialyticst / app.py
sqy-harshil's picture
Rename main.py to app.py
7e9341d
import streamlit as st
import streamlit_chat as stc
import uuid
from helper import get_data, convert_url, collection
st.set_page_config(layout="wide")
option = st.sidebar.selectbox(
placeholder="Choose an MP3...",
label="**MP3**",
options=collection.distinct("mp3"),
index=None,
)
if option:
st.title("Get Call Analysis Data")
st.audio(convert_url(option), start_time=0, format='audio/mp3')
data = get_data(option)
mp3 = data["mp3"]
transcript = data["transcript"]
summary = data["summary"]
ratings = data["ratings"]
cost = data["cost"]
col1, col2 = st.columns(2)
with col1:
st.title(
"Ratings", help="The ratings given by the AI based on your prompts"
)
col31, col32, col33 = st.columns(3)
with col31:
st.text_input(
label="**Rudeness or politeness metric**",
value=ratings["rudeness_or_politeness_metric"],
disabled=True,
)
st.text_input(
label="**Salesperson company introduction**",
value=ratings["salesperson_company_introduction"],
disabled=True,
)
st.text_input(
label="**Meeting request**",
value=ratings["meeting_request"],
disabled=True,
)
with col32:
st.text_input(
label="**Salesperson's convincing abilities**",
value=ratings["salesperson_convincing_abilities"],
disabled=True,
)
st.text_input(
label="**Understanding of requirements**",
value=ratings["salesperson_understanding_of_customer_requirements"],
disabled=True,
)
st.text_input(
label="**Customer sentiment**",
value=ratings["customer_sentiment_by_the_end_of_call"],
disabled=True,
)
with col33:
st.text_input(
label="**Customer's eagerness to buy**",
value=ratings["customer_eagerness_to_buy"],
disabled=True,
)
st.text_input(
label="**Customer's budget**",
value=ratings["customer_budget"],
disabled=True,
)
st.text_input(
label="**Customer preferences**",
value=ratings["customer_preferences"],
disabled=True,
)
st.text_input(label="Cost", value=cost, disabled=True)
st.title("Meeting Notes", help="The call summary")
st.markdown(f"## {summary['title']}")
# Display discussion points
st.markdown("### Discussion Points")
st.markdown(summary["discussion_points"])
# Display customer queries
st.markdown("### Customer Queries")
st.markdown(summary["customer_queries"])
# Display next action items
st.markdown("### Next Action Items")
st.markdown(summary["next_action_items"])
with col2:
st.title(
"Diarized Output", help="This conversation comes from the deepgram API"
)
with st.expander(label="View the Raw Transcript"):
st.text_area(
label="Raw Transcript",
value=transcript,
height=450,
)
for i in transcript.split("\n"):
if "salesperson" in i:
temp = i.replace("salesperson", "").replace(":", "")
st.write(
f"""
<div style="display: flex; justify-content: flex-start; padding:5px; align-items: center; max-width: 700px"><span>πŸ‘¨πŸΎβ€πŸ’Ό</span> <span style="background-color: #E0E0E0; padding: 5px; border-radius: 5px;">{temp}</span></div>
""",
unsafe_allow_html=True,
)
elif "customer" in i:
temp = i.replace("customer", "").replace(":", "")
st.write(
f"""
<div style="display: flex; justify-content: flex-end; padding:5px; align-items: center; max-width:700px"><span style="background-color: #63b076; padding: 5px; border-radius: 5px; max-width:300px">{temp}</span><span>πŸ‘€</span></div>
""",
unsafe_allow_html=True,
)
else:
stc.message(
message=i, avatar_style="no-avatar", key=str(uuid.uuid4())
)
else:
st.warning("Choose an MP3 to view analysis!")