bikas commited on
Commit
10e4a1f
1 Parent(s): ab53c7f

Minutes of Meetings

Browse files
Files changed (1) hide show
  1. app.py +140 -0
app.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from groq import Groq
4
+ from dotenv import load_dotenv
5
+ from datetime import datetime # Import datetime module
6
+
7
+ # Load environment variables
8
+ load_dotenv()
9
+
10
+ # Ensure 'data' folder exists (use lowercase 'data' for consistency)
11
+ if not os.path.exists("data"):
12
+ os.makedirs("data")
13
+
14
+ # Function to get speech transcription from audio
15
+ def get_speech_transcription(audio_file):
16
+ client = Groq(api_key=os.getenv("GROQ_API_KEY"))
17
+
18
+ # Read the audio file content
19
+ transcription = client.audio.transcriptions.create(
20
+ file=(audio_file.name, audio_file.read()),
21
+ model="whisper-large-v3", # Use the appropriate model
22
+ response_format="verbose_json",
23
+ )
24
+
25
+ return transcription.text
26
+
27
+ # Function to get Groq completions for the transcript
28
+ def get_groq_completions(user_content):
29
+ client = Groq(api_key=os.getenv("GROQ_API_KEY"))
30
+
31
+ prompt = f"""
32
+ You will be provided with a transcript of a meeting.
33
+ Summarize the key points from the transcript in a structured format.
34
+ If any new topics are discussed, make them as a title and corresponding discussion will be description using number points also add time how much time they discuss on those topics.
35
+
36
+ \n{user_content}
37
+ """
38
+
39
+ completion = client.chat.completions.create(
40
+ model="llama-3.2-90b-text-preview",
41
+ messages=[
42
+ {
43
+ "role": "system",
44
+ "content": "You are a helpful AI assistant."
45
+ },
46
+ {
47
+ "role": "user",
48
+ "content": prompt
49
+ }
50
+ ],
51
+ temperature=0.8,
52
+ max_tokens=6000,
53
+ top_p=1,
54
+ stream=True,
55
+ stop=None,
56
+ )
57
+
58
+ result = ""
59
+ for chunk in completion:
60
+ result += chunk.choices[0].delta.content or ""
61
+
62
+ return result
63
+
64
+ # Function to save the user content in a file
65
+ def save_user_content(email, content):
66
+ # Get the current date and time
67
+ current_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
68
+
69
+ # Create filename using email and current timestamp
70
+ filename = f"{email}_{current_time}.txt"
71
+
72
+ file_path = os.path.join("data", filename) # Ensure 'data' directory is used
73
+ with open(file_path, "w") as f:
74
+ f.write(content)
75
+
76
+ return file_path # Return the file path for confirmation
77
+
78
+ # Streamlit interface
79
+ def main():
80
+ # Add project title
81
+ st.title("Minutes of Meetings") # Add title here
82
+ st.sidebar.title("Upload Options")
83
+
84
+ # User email input
85
+ email = st.sidebar.text_input("Please enter your email address:")
86
+
87
+ # Sidebar options
88
+ upload_option = st.sidebar.selectbox("Choose how to provide the content:",
89
+ ("Upload Audio File", "Upload Text File", "Paste Text"))
90
+
91
+ user_content = ""
92
+
93
+ # Conditional logic based on sidebar selection
94
+ if upload_option == "Upload Audio File":
95
+ audio_file = st.sidebar.file_uploader("Upload an audio file", type=["mp3", "wav", "m4a"])
96
+
97
+ if audio_file and st.sidebar.button("Generate MoM from Audio"):
98
+ if not email:
99
+ st.warning("Please enter your email address.")
100
+ return
101
+ st.info("Transcribing audio... Please wait.")
102
+ user_content = get_speech_transcription(audio_file)
103
+ st.success("Audio transcribed successfully!")
104
+
105
+ elif upload_option == "Upload Text File":
106
+ text_file = st.sidebar.file_uploader("Upload a text file", type=["txt"])
107
+
108
+ if text_file and st.sidebar.button("Generate MoM from Text File"):
109
+ if not email:
110
+ st.warning("Please enter your email address.")
111
+ return
112
+ user_content = text_file.read().decode("utf-8")
113
+ st.success("Text file uploaded successfully!")
114
+
115
+ elif upload_option == "Paste Text":
116
+ user_content = st.sidebar.text_area("Paste your text here:")
117
+
118
+ if st.sidebar.button("Generate MoM from Pasted Text"):
119
+ if not email:
120
+ st.warning("Please enter your email address.")
121
+ return
122
+ if not user_content:
123
+ st.warning("Please paste some text before generating the MoM.")
124
+ return
125
+
126
+ if user_content:
127
+ st.info("Generating MoM... Please wait.")
128
+
129
+ # Save user content and get file path
130
+ file_path = save_user_content(email, user_content)
131
+
132
+ # Generate MoM
133
+ generated_mom = get_groq_completions(user_content)
134
+
135
+ # Display the generated MoM
136
+ st.markdown("### Generated MoM:")
137
+ st.text_area("", value=generated_mom, height=500)
138
+
139
+ if __name__ == "__main__":
140
+ main()