from langchain_core.messages import SystemMessage, HumanMessage from langchain_openai import ChatOpenAI def audio_transcript_tool(base64_audio: str) -> str: """ Get a transcript of an audio file. Args: base64_audio (str): Base64 encoded audio file. Returns: str: The transcript of the audio file. """ print(f"audio_transcript_tool called: {base64_audio[:50]}...") system_message = SystemMessage(content="Transcribe the provided audio file and return the transcribed text only.") audio_message = HumanMessage(content=[{ "type": "input_audio", "input_audio": { "data": base64_audio, "format": "mp3", } }]) messages = [system_message, audio_message] # Get the response from the LLM llm = ChatOpenAI(model="gpt-4o-mini-audio-preview") response = llm.invoke(messages) answer = response.content print(f"audio_transcript_tool response: {answer}") return answer