binhqd commited on
Commit
1e1da0c
·
1 Parent(s): f58e011

Add custom inference handler for Maya1 TTS

Browse files
Files changed (1) hide show
  1. 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 {"audio_base64": b64, "sampling_rate": sr}
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
- return {
341
- "audio_base64": b64,
342
- "sampling_rate": 24000,
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.