"""Tool for transcribing audio files to text.""" import os from langchain_core.tools import tool from langchain_community.document_loaders import AssemblyAIAudioTranscriptLoader @tool def audio_transcription(file_path: str) -> str: """ Transcribe an audio file to text using AssemblyAI. Args: file_path: The path to the audio file. Returns: The transcribed text from the audio file. """ search_docs = AssemblyAIAudioTranscriptLoader(file_path=file_path).load() formatted_search_docs = "\n\n---\n\n".join( [ f'\n{doc.page_content}\n' for doc in search_docs ]) return {"audio_results": formatted_search_docs}