Upload 3 files
Browse files- app.py +35 -0
- requirements.txt +0 -0
- utils.py +43 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from utils import *
|
3 |
+
|
4 |
+
|
5 |
+
# Define the Streamlit app
|
6 |
+
def main():
|
7 |
+
st.title("Customer Care Call Summarization")
|
8 |
+
|
9 |
+
# Upload multiple files
|
10 |
+
uploaded_files = st.file_uploader("Upload recorded .mp3 files", type=["mp3"], accept_multiple_files=True)
|
11 |
+
|
12 |
+
if uploaded_files:
|
13 |
+
st.write("Uploaded Files:")
|
14 |
+
|
15 |
+
# Display uploaded files and buttons in a tabular form
|
16 |
+
for uploaded_file in uploaded_files:
|
17 |
+
file_name = uploaded_file.name
|
18 |
+
|
19 |
+
|
20 |
+
col1, col2, col3 = st.columns([0.1, 1, 2])
|
21 |
+
with col1:
|
22 |
+
st.write("-")
|
23 |
+
with col2:
|
24 |
+
st.write(file_name)
|
25 |
+
with col3:
|
26 |
+
send_button = st.button(f"Send Email for {file_name}")
|
27 |
+
|
28 |
+
if send_button:
|
29 |
+
email_summary(file_name)
|
30 |
+
st.success(f"Send email for: {file_name}")
|
31 |
+
|
32 |
+
|
33 |
+
# Run the Streamlit app
|
34 |
+
if __name__ == "__main__":
|
35 |
+
main()
|
requirements.txt
ADDED
Binary file (202 Bytes). View file
|
|
utils.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import whisper
|
2 |
+
from langchain.llms import OpenAI
|
3 |
+
from langchain.agents import initialize_agent
|
4 |
+
from langchain.agents.agent_toolkits import ZapierToolkit
|
5 |
+
from langchain.utilities.zapier import ZapierNLAWrapper
|
6 |
+
import os
|
7 |
+
|
8 |
+
# get from https://platform.openai.com/
|
9 |
+
os.environ["OPENAI_API_KEY"] = "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"
|
10 |
+
|
11 |
+
# get from https://nla.zapier.com/docs/authentication/ & https://actions.zapier.com/credentials/ after logging in):
|
12 |
+
os.environ["ZAPIER_NLA_API_KEY"] = "sk-ak-iPp3rBjaP9PpjRDpDhIXtsXsCj"
|
13 |
+
|
14 |
+
|
15 |
+
def email_summary(file):
|
16 |
+
|
17 |
+
|
18 |
+
# large language model
|
19 |
+
llm = OpenAI(temperature=0)
|
20 |
+
|
21 |
+
# Initializing zapier
|
22 |
+
zapier = ZapierNLAWrapper()
|
23 |
+
toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)
|
24 |
+
|
25 |
+
# The agent used here is a "zero-shot-react-description" agent.
|
26 |
+
# Zero-shot means the agent functions on the current action only — it has no memory.
|
27 |
+
# It uses the ReAct framework to decide which tool to use, based solely on the tool's description.
|
28 |
+
agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True)
|
29 |
+
|
30 |
+
|
31 |
+
# specify a model, here its BASE
|
32 |
+
model = whisper.load_model("base")
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
# transcribe audio file
|
37 |
+
result = model.transcribe(file)
|
38 |
+
print(result["text"])
|
39 |
+
|
40 |
+
# Send email using zapier
|
41 |
+
agent.run("Send an Email to [email protected] via gmail summarizing the following text provided below : "+result["text"])
|
42 |
+
|
43 |
+
|