import os from langchain_community.document_loaders import AssemblyAIAudioTranscriptLoader from smolagents import Tool class AssemblyAIAudioTranscriptTool(Tool): name = "AssemblyAIAudioTranscriptTool" description = "This tool extracts transcripts from audio file using AssemblyAI." inputs = { "url": { "type": "string", "description": "the URL for the audio file.", } } output_type = "string" def forward(self, url: str) -> str: """ Extracts the transcript from the audio file using AssemblyAI. https://python.langchain.com/docs/integrations/document_loaders/assemblyai/ """ loader = AssemblyAIAudioTranscriptLoader( file_path=url, api_key=os.getenv("ASSEMBLYAI_API_KEY") ) document = loader.load() return document[0].page_content