gautamtata commited on
Commit
9705ce9
1 Parent(s): 4d96b82

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -15
handler.py CHANGED
@@ -164,20 +164,13 @@ class EndpointHandler():
164
 
165
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
166
  """
167
- The method called during inference. Expects data to have a 'url' to the audio file.
168
  """
169
- # Get the URL to the audio file from the request data
170
- url = data.get("url")
171
-
172
- # If the URL is provided, download the file and run the prediction
173
- if url:
174
- file_path = self.download_file(url)
175
- if file_path:
176
- output = self.predict(file_path)
177
- # Optionally, delete the temporary file
178
- os.remove(file_path)
179
- return output
180
- else:
181
- return {"error": "Could not download the file from the provided URL."}
182
  else:
183
- return {"error": "URL to the audio file is required."}
 
164
 
165
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
166
  """
167
+ The actual method called during inference. Expects data to have a 'path' to the audio file.
168
  """
169
+ # Get the path to the audio file from the request data
170
+ path = data.get("path")
171
+
172
+ # If the path is provided, we run the prediction, else return an error message
173
+ if path:
174
+ return self.predict(path)
 
 
 
 
 
 
 
175
  else:
176
+ return {"error": "Path to the audio file is required."}