import whisper from langchain.llms import OpenAI from langchain.agents import initialize_agent from langchain.agents.agent_toolkits import ZapierToolkit from langchain.utilities.zapier import ZapierNLAWrapper import os # Set up API keys os.environ["OPENAI_API_KEY"] = "sk-proj-j70hae3tYEWKJxprAgQTT3BlbkFJwjjY9VyVZPm2hKrBt82c" os.environ["ZAPIER_NLA_API_KEY"] = "sk-ak-ACaspkBllFPiU0EHUtqXi6FiEU" def transcribe_audio(uploaded_file): # Load Whisper model model = whisper.load_model("base") # Save uploaded file to a temporary file with open("temp_audio.mp3", "wb") as f: f.write(uploaded_file.getbuffer()) # Transcribe audio file result = model.transcribe("temp_audio.mp3") transcribed_text = result["text"] print(transcribed_text) # Return transcribed text return transcribed_text def send_summary_email(transcribed_text): # Initialize the large language model llm = OpenAI(temperature=0) # Initialize Zapier zapier = ZapierNLAWrapper() toolkit = ZapierToolkit(zapier_nla_wrapper=zapier) # Get tools from the toolkit tools = toolkit.get_tools() if not tools: raise ValueError("No tools available for the agent to use.") # Initialize the agent with the tools agent = initialize_agent( tools=tools, llm=llm, agent="zero-shot-react-description", verbose=True ) # Send email using Zapier summary = f"Send an Email to mehrdaddjavadi@gmail.com via gmail summarizing the following text provided below: {transcribed_text}" agent.run(summary) return summary