bikas
Minutes of Meetings
10e4a1f
raw
history blame
4.76 kB
import os
import streamlit as st
from groq import Groq
from dotenv import load_dotenv
from datetime import datetime # Import datetime module
# Load environment variables
load_dotenv()
# Ensure 'data' folder exists (use lowercase 'data' for consistency)
if not os.path.exists("data"):
os.makedirs("data")
# Function to get speech transcription from audio
def get_speech_transcription(audio_file):
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
# Read the audio file content
transcription = client.audio.transcriptions.create(
file=(audio_file.name, audio_file.read()),
model="whisper-large-v3", # Use the appropriate model
response_format="verbose_json",
)
return transcription.text
# Function to get Groq completions for the transcript
def get_groq_completions(user_content):
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
prompt = f"""
You will be provided with a transcript of a meeting.
Summarize the key points from the transcript in a structured format.
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.
\n{user_content}
"""
completion = client.chat.completions.create(
model="llama-3.2-90b-text-preview",
messages=[
{
"role": "system",
"content": "You are a helpful AI assistant."
},
{
"role": "user",
"content": prompt
}
],
temperature=0.8,
max_tokens=6000,
top_p=1,
stream=True,
stop=None,
)
result = ""
for chunk in completion:
result += chunk.choices[0].delta.content or ""
return result
# Function to save the user content in a file
def save_user_content(email, content):
# Get the current date and time
current_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Create filename using email and current timestamp
filename = f"{email}_{current_time}.txt"
file_path = os.path.join("data", filename) # Ensure 'data' directory is used
with open(file_path, "w") as f:
f.write(content)
return file_path # Return the file path for confirmation
# Streamlit interface
def main():
# Add project title
st.title("Minutes of Meetings") # Add title here
st.sidebar.title("Upload Options")
# User email input
email = st.sidebar.text_input("Please enter your email address:")
# Sidebar options
upload_option = st.sidebar.selectbox("Choose how to provide the content:",
("Upload Audio File", "Upload Text File", "Paste Text"))
user_content = ""
# Conditional logic based on sidebar selection
if upload_option == "Upload Audio File":
audio_file = st.sidebar.file_uploader("Upload an audio file", type=["mp3", "wav", "m4a"])
if audio_file and st.sidebar.button("Generate MoM from Audio"):
if not email:
st.warning("Please enter your email address.")
return
st.info("Transcribing audio... Please wait.")
user_content = get_speech_transcription(audio_file)
st.success("Audio transcribed successfully!")
elif upload_option == "Upload Text File":
text_file = st.sidebar.file_uploader("Upload a text file", type=["txt"])
if text_file and st.sidebar.button("Generate MoM from Text File"):
if not email:
st.warning("Please enter your email address.")
return
user_content = text_file.read().decode("utf-8")
st.success("Text file uploaded successfully!")
elif upload_option == "Paste Text":
user_content = st.sidebar.text_area("Paste your text here:")
if st.sidebar.button("Generate MoM from Pasted Text"):
if not email:
st.warning("Please enter your email address.")
return
if not user_content:
st.warning("Please paste some text before generating the MoM.")
return
if user_content:
st.info("Generating MoM... Please wait.")
# Save user content and get file path
file_path = save_user_content(email, user_content)
# Generate MoM
generated_mom = get_groq_completions(user_content)
# Display the generated MoM
st.markdown("### Generated MoM:")
st.text_area("", value=generated_mom, height=500)
if __name__ == "__main__":
main()