Spaces:
Sleeping
Sleeping
Deploy HARP wrapper via model agent
Browse filesFiles changed (4)
- .harp/manifest.jsonAdded+21
- README.md+13-7
- app.pyAdded+91
- requirements.txtAdded+3
123456789101112131415161718192021{ "backend_space": "REPLACE_WITH_YOUR_BACKEND_SPACE", "deploy_mode": "remote-backend", "entry": "app.py", "framework": "gradio_client", "generated": true, "io": { "inputs": [ "textbox", "slider", "number" ], "outputs": [ "audio" ] }, "repo_id": "SonyResearch/Woosh", "source": "recipe", "space_layout": "huggingface-gradio", "task": "text-to-audio"}12345678910111213---title: Woosh Dflowemoji: 🐠colorFrom: pinkcolorTo: bluesdk: gradiosdk_version: 6.19.0python_version: '3.13'app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213141516171819---title: "Woosh-DFlow (Text-to-Audio SFX)"colorFrom: indigocolorTo: graysdk: gradiosdk_version: 5.28.0app_file: app.pypinned: falselicense: "cc-by-nc-4.0"---# Woosh-DFlow (Text-to-Audio SFX)Generate a ~5s, 48kHz sound effect from a text prompt using Sony AI's Woosh-DFlow, the distilled (4-step) text-to-audio model from the Woosh sound-effect foundation model family. This is a thin HARP frontend that proxies to a Woosh-DFlow backend Space over its /generate API; the heavy model (Python 3.12, torch 2.8, Gradio 6) runs there, unmodified. Open weights are CC-BY-NC 4.0 (non-commercial).- Inputs: textbox, slider, number- Outputs: audioGenerated by the HARP model agent from a recipe.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091from __future__ import annotations
import os
import gradio as gr
from pyharp import *from gradio_client import Client, handle_file
_BACKEND_SPACE = "REPLACE_WITH_YOUR_BACKEND_SPACE"_BACKEND_API_NAME = "/generate"_BACKEND_TOKEN_ENV = "HF_TOKEN"_ACCEPT_USER_TOKEN = False_client = None
def _backend_client(): # Lazily create and cache one warm connection using this Space's own # token (from the HF_TOKEN secret) or anonymous if none is set. User # tokens are NOT cached here -- they get a fresh per-call connection. global _client if _client is None: _token = os.environ.get(_BACKEND_TOKEN_ENV) or None _client = Client(_BACKEND_SPACE, hf_token=_token) return _client
def _quota_hint(message): # Turn a backend ZeroGPU quota error into an actionable message. # NOTE: 'message' is the backend's error text; it never contains our token. _low = (message or "").lower() if "quota" in _low or "zerogpu" in _low: if _ACCEPT_USER_TOKEN: return ( "The backend's ZeroGPU quota is exhausted for the identity making " "this call. Paste your own Hugging Face token in the token field " "(read scope) so usage is attributed to your account." ) return ( "The backend's ZeroGPU quota is exhausted. This Space's calls are " "anonymous unless an HF_TOKEN secret is set (Settings -> Variables " "and secrets); use a token from a PRO account or a ZeroGPU-enabled org." ) return message or "Backend call failed."
model_card = ModelCard( name="Woosh-DFlow (Text-to-Audio SFX)", description="Generate a ~5s, 48kHz sound effect from a text prompt using Sony AI's Woosh-DFlow, the distilled (4-step) text-to-audio model from the Woosh sound-effect foundation model family. This is a thin HARP frontend that proxies to a Woosh-DFlow backend Space over its /generate API; the heavy model (Python 3.12, torch 2.8, Gradio 6) runs there, unmodified. Open weights are CC-BY-NC 4.0 (non-commercial).", author="Sony AI (Hadjeres, Ferras, Koutini, Weck, Bittar, Hummel, Lahrichi, Missoum, Serra, Mitsufuji)", tags=["text-to-audio", "sound-effects", "sfx", "generative-audio"],)
def process_fn(prompt, cfg_scale, seed): _conn = _backend_client() try: _raw = _conn.predict( prompt, float(cfg_scale), int(seed), api_name="/generate", ) except Exception as _exc: # surface a token-aware hint, never the token raise gr.Error(_quota_hint(str(_exc))) _values = list(_raw) if isinstance(_raw, (list, tuple)) else [_raw] _detail = " | ".join(str(_v) for _v in _values if isinstance(_v, str) and _v.strip()) _out_audio = _values[0] if len(_values) > 0 else None if not _out_audio: raise gr.Error(_detail or "The backend Space returned no 'audio' output. Check the backend Space's logs; if it uses ZeroGPU it may need a moment to warm up.") return _out_audio
with gr.Blocks() as demo: input_components = [ gr.Textbox(label="Prompt", info="Describe the sound effect to generate, e.g. 'sportscar engine revving and driving away quickly'."), gr.Slider(minimum=0.0, maximum=15.0, step=0.1, value=4.5, label="CFG scale", info="Classifier-free guidance strength: higher follows the prompt more closely."), gr.Number(value=-1, label="Seed", info="Random seed; use -1 for a new random result each run."), ] output_components = [ gr.Audio(type="filepath", label="Generated sound effect"), ] build_endpoint( model_card=model_card, input_components=input_components, output_components=output_components, process_fn=process_fn, )
demo.queue().launch(share=True, show_error=False, pwa=True)123git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0gradio>=4.0gradio_client.harp/manifest.jsonAdded+21
README.md+13-7
app.pyAdded+91
requirements.txtAdded+3