Update tools/transcribe_audio.py
Browse files
tools/transcribe_audio.py
CHANGED
|
@@ -1,4 +1,8 @@
|
|
| 1 |
from langchain_core.tools import tool
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
@tool("transcribe_audio", parse_docstring=True)
|
| 4 |
def transcribe_audio(file_name: str) -> str:
|
|
@@ -26,10 +30,3 @@ def transcribe_audio(file_name: str) -> str:
|
|
| 26 |
except Exception as e:
|
| 27 |
print(f"Error transcribing audio: {str(e)}")
|
| 28 |
return ""
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
if __name__ == "__main__":
|
| 32 |
-
print(transcribe_audio.invoke("../data/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3"))
|
| 33 |
-
print(transcribe_audio.invoke(
|
| 34 |
-
"https://agents-course-unit4-scoring.hf.space/files/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3"))
|
| 35 |
-
|
|
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
+
from loguru import logger
|
| 3 |
+
import tempfile
|
| 4 |
+
import whisper
|
| 5 |
+
from tools.load_file import load_file
|
| 6 |
|
| 7 |
@tool("transcribe_audio", parse_docstring=True)
|
| 8 |
def transcribe_audio(file_name: str) -> str:
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
print(f"Error transcribing audio: {str(e)}")
|
| 32 |
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|