KaiserShultz commited on
Commit
012c173
·
verified ·
1 Parent(s): bd9d9f5

Update src/tools/tools.py

Browse files
Files changed (1) hide show
  1. src/tools/tools.py +15 -0
src/tools/tools.py CHANGED
@@ -19,6 +19,7 @@ from langchain_community.tools.tavily_search import TavilySearchResults
19
  from langchain_community.document_loaders import ArxivLoader
20
  from langchain_community.document_loaders import WikipediaLoader
21
  from PIL import ImageDraw, ImageFont, ImageEnhance, ImageFilter
 
22
  from src.utils.image_processing import *
23
  import re
24
 
@@ -930,3 +931,17 @@ def download_file_from_url(url: str, filename: Optional[str] = None) -> str:
930
  return f"File downloaded to {filepath}. You can read this file to process its contents."
931
  except Exception as e:
932
  return f"Error downloading file: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  from langchain_community.document_loaders import ArxivLoader
20
  from langchain_community.document_loaders import WikipediaLoader
21
  from PIL import ImageDraw, ImageFont, ImageEnhance, ImageFilter
22
+ from langchain_community.tools.tavily_search import TavilySearchResults
23
  from src.utils.image_processing import *
24
  import re
25
 
 
931
  return f"File downloaded to {filepath}. You can read this file to process its contents."
932
  except Exception as e:
933
  return f"Error downloading file: {str(e)}"
934
+
935
+
936
+ @tool
937
+ def transcribe_audio(audio_file: str) -> str:
938
+ """
939
+ Transcribe an audio file (URL or local path) using AssemblyAI and return the transcript text.
940
+ """
941
+ try:
942
+ loader = AssemblyAIAudioTranscriptLoader(file_path=audio_file)
943
+ docs = loader.load()
944
+ #only text
945
+ return docs[0].page_content if docs else "No transcription result."
946
+ except Exception as e:
947
+ return f"transcribe_error:{str(e)}"