gautamtata
commited on
Commit
•
9705ce9
1
Parent(s):
4d96b82
Update handler.py
Browse files- 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 '
|
168 |
"""
|
169 |
-
# Get the
|
170 |
-
|
171 |
-
|
172 |
-
# If the
|
173 |
-
if
|
174 |
-
|
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": "
|
|
|
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."}
|