Add custom inference handler for Maya1 TTS
Browse files- handler.py +4 -5
handler.py
CHANGED
|
@@ -274,7 +274,7 @@ class EndpointHandler:
|
|
| 274 |
wav_bytes = buf.getvalue()
|
| 275 |
b64 = base64.b64encode(wav_bytes).decode("utf-8")
|
| 276 |
|
| 277 |
-
return {"
|
| 278 |
|
| 279 |
# Build properly formatted prompt for Maya1
|
| 280 |
prompt = self.build_prompt(description, text)
|
|
@@ -337,10 +337,9 @@ class EndpointHandler:
|
|
| 337 |
wav_bytes = buf.getvalue()
|
| 338 |
b64 = base64.b64encode(wav_bytes).decode("utf-8")
|
| 339 |
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
}
|
| 344 |
# Module-level convenience functions for hosting platforms (Hugging Face Endpoints)
|
| 345 |
# The platform typically expects top-level `init` and `predict` (or `run`) callables
|
| 346 |
# so we provide thin wrappers around the EndpointHandler class.
|
|
|
|
| 274 |
wav_bytes = buf.getvalue()
|
| 275 |
b64 = base64.b64encode(wav_bytes).decode("utf-8")
|
| 276 |
|
| 277 |
+
return [{"blob": b64, "content-type": "audio/wav"}]
|
| 278 |
|
| 279 |
# Build properly formatted prompt for Maya1
|
| 280 |
prompt = self.build_prompt(description, text)
|
|
|
|
| 337 |
wav_bytes = buf.getvalue()
|
| 338 |
b64 = base64.b64encode(wav_bytes).decode("utf-8")
|
| 339 |
|
| 340 |
+
# Return in HuggingFace Inference Endpoints format
|
| 341 |
+
# The endpoint expects a list with blob data
|
| 342 |
+
return [{"blob": b64, "content-type": "audio/wav"}]
|
|
|
|
| 343 |
# Module-level convenience functions for hosting platforms (Hugging Face Endpoints)
|
| 344 |
# The platform typically expects top-level `init` and `predict` (or `run`) callables
|
| 345 |
# so we provide thin wrappers around the EndpointHandler class.
|