Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -4,19 +4,6 @@ from smolagents import tool
|
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
-
@tool
|
| 8 |
-
def extract_text_from_audio(file_path : str) -> str:
|
| 9 |
-
"""given a path to an audio file, it extract and returns the text contained in it as a string"""
|
| 10 |
-
|
| 11 |
-
import speech_recognition as sr
|
| 12 |
-
r = sr.Recognizer()
|
| 13 |
-
with sr.AudioFile(file_path) as source:
|
| 14 |
-
# listen for the data (load audio to memory)
|
| 15 |
-
audio_data = r.record(source)
|
| 16 |
-
# recognize (convert from speech to text)
|
| 17 |
-
text = r.recognize_google(audio_data)
|
| 18 |
-
return text
|
| 19 |
-
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def extract_text_from_audio(file_path: str) -> str:
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@tool
|
| 9 |
def extract_text_from_audio(file_path: str) -> str:
|