Spaces:
Running on Zero
Running on Zero
Download handler.py from suno/bark: direct link, hf CLI and curl.
- Browser
- Download file 545 Bytes
-
https://huggingface.co/spaces/suno/bark/resolve/refs%2Fpr%2F226/handler.py
- Command line
-
hf download hf://spaces/suno/bark@refs/pr/226/handler.py
-
curl -L -o handler.py https://huggingface.co/spaces/suno/bark/resolve/refs%2Fpr%2F226/handler.py
545 Bytes
| from typing import Dict, Any | |
| from transformers import pipeline | |
| class EndpointHandler(): | |
| def __init__(self, path: str = ""): | |
| self.pipe = pipeline("text-to-speech", model="suno/bark", device=0) | |
| def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]: | |
| inputs = data.pop("inputs", data) | |
| try: | |
| audio = self.pipe(inputs) | |
| return { | |
| "audio": audio.tolist(), | |
| "sampling_rate": 24000 | |
| } | |
| except Exception as e: | |
| return {"error": str(e)} |