petrov826 commited on
Commit
b027ebf
·
verified ·
1 Parent(s): 82f0dfe

Create assemblyai_audio__transcript_tool.py

Browse files
assemblyai_audio__transcript_tool.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.document_loaders import AssemblyAIAudioTranscriptLoader
2
+ from smolagents import Tool
3
+
4
+ class AssemblyAIAudioTranscriptTool(Tool):
5
+ name = "AssemblyAIAudioTranscriptTool"
6
+ description = "This tool extracts transcripts from audio file using AssemblyAI."
7
+
8
+ inputs = {
9
+ "url": {
10
+ "type": "string",
11
+ "description": "the URL for the audio file.",
12
+ }
13
+ }
14
+
15
+ output_type = "string"
16
+
17
+ def forward(self, url: str) -> str:
18
+ """
19
+ Extracts the transcript from the audio file using AssemblyAI.
20
+ https://python.langchain.com/docs/integrations/document_loaders/assemblyai/
21
+ """
22
+ loader = AssemblyAIAudioTranscriptLoader(
23
+ file_path=url,
24
+ api_key=userdata.get("ASSEMBLYAI_API_KEY")
25
+ )
26
+ document = loader.load()
27
+ return document[0].page_content