SergeyO7 commited on
Commit
45db113
·
verified ·
1 Parent(s): 6f0054b

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +9 -1
agent.py CHANGED
@@ -87,11 +87,19 @@ class SpeechToTextTool(Tool):
87
 
88
  def __init__(self):
89
  super().__init__()
90
- self.model = whisper.load_model("base")
 
 
 
 
 
 
91
 
92
  def forward(self, audio_path: str) -> str:
93
  if not os.path.exists(audio_path):
94
  return f"Error: File not found at {audio_path}"
 
 
95
  try:
96
  print(f"Starting transcription for {audio_path}...")
97
  result = self.model.transcribe(audio_path)
 
87
 
88
  def __init__(self):
89
  super().__init__()
90
+ try:
91
+ print("Loading whisper model 'base'...")
92
+ self.model = whisper.load_model("base")
93
+ print("Whisper model loaded successfully.")
94
+ except Exception as e:
95
+ print(f"Error loading whisper model: {e}")
96
+ self.model = None
97
 
98
  def forward(self, audio_path: str) -> str:
99
  if not os.path.exists(audio_path):
100
  return f"Error: File not found at {audio_path}"
101
+ if self.model is None:
102
+ return "Error: Whisper model failed to load during initialization."
103
  try:
104
  print(f"Starting transcription for {audio_path}...")
105
  result = self.model.transcribe(audio_path)