Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ def parse_csv(file_path: str) -> str:
|
|
| 45 |
@tool
|
| 46 |
def transcribe_audio(audio_path: str) -> str:
|
| 47 |
"""
|
| 48 |
-
Transcribes spoken words in an audio file.
|
| 49 |
|
| 50 |
Args:
|
| 51 |
audio_path: Path to the .mp3 or .wav file.
|
|
@@ -54,9 +54,17 @@ def transcribe_audio(audio_path: str) -> str:
|
|
| 54 |
A transcription of the audio content as a string.
|
| 55 |
"""
|
| 56 |
import whisper
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# === Tool 4: Web Search Tool ===
|
| 62 |
@tool
|
|
|
|
| 45 |
@tool
|
| 46 |
def transcribe_audio(audio_path: str) -> str:
|
| 47 |
"""
|
| 48 |
+
Transcribes spoken words in an audio file using Whisper.
|
| 49 |
|
| 50 |
Args:
|
| 51 |
audio_path: Path to the .mp3 or .wav file.
|
|
|
|
| 54 |
A transcription of the audio content as a string.
|
| 55 |
"""
|
| 56 |
import whisper
|
| 57 |
+
import os
|
| 58 |
+
|
| 59 |
+
if not os.path.exists(audio_path):
|
| 60 |
+
return f"File not found: {audio_path}"
|
| 61 |
+
|
| 62 |
+
try:
|
| 63 |
+
model = whisper.load_model("base")
|
| 64 |
+
result = model.transcribe(audio_path)
|
| 65 |
+
return result.get("text", "No transcription result.")
|
| 66 |
+
except Exception as e:
|
| 67 |
+
return f"Transcription error: {e}"
|
| 68 |
|
| 69 |
# === Tool 4: Web Search Tool ===
|
| 70 |
@tool
|