portmafia9719 commited on
Commit
5ba9c45
·
1 Parent(s): 76f2900

Update tools and requirements

Browse files
Files changed (2) hide show
  1. requirements.txt +2 -1
  2. tools.py +6 -4
requirements.txt CHANGED
@@ -5,4 +5,5 @@ smolagents[openai]
5
  duckduckgo-search
6
  youtube-transcript-api
7
  pytesseract
8
- pillow
 
 
5
  duckduckgo-search
6
  youtube-transcript-api
7
  pytesseract
8
+ pillow
9
+ assemblyai
tools.py CHANGED
@@ -130,12 +130,14 @@ class AudioTranscriptionTool(Tool):
130
  output_type = "string"
131
 
132
  def forward(self, path: str, model: str = "whisper-1") -> str:
133
- import openai
 
 
134
  if not os.path.isfile(path):
135
  raise FileNotFoundError(path)
136
- client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
137
- with open(path, "rb") as fp:
138
- transcript = client.audio.transcriptions.create(model=model, file=fp)
139
  return str(transcript.text.strip())
140
 
141
  # ---- 5. SimpleOCRTool ------------------------------------------------------
 
130
  output_type = "string"
131
 
132
  def forward(self, path: str, model: str = "whisper-1") -> str:
133
+ import assemblyai as aai
134
+ aai.settings.api_key = os.getenv("ASSEMBLY_AI_API_KEY")
135
+ config = aai.TranscriptionConfig(speech_model=aai.SpeechModel.best)
136
  if not os.path.isfile(path):
137
  raise FileNotFoundError(path)
138
+ transcript = aai.Transcriber(config=config).transcribe(data=path)
139
+ if transcript.status == "error":
140
+ raise RuntimeError(f"Transcription failed: {transcript.error}")
141
  return str(transcript.text.strip())
142
 
143
  # ---- 5. SimpleOCRTool ------------------------------------------------------