Spaces:
Sleeping
Sleeping
File size: 886 Bytes
8b36e77 b027ebf 8b36e77 b027ebf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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 |