harp-dev commited on
Commit
973fcf5
·
verified ·
1 Parent(s): de32596

Deploy HARP wrapper via model agent

Browse files
Files changed (4) hide show
  1. .harp/manifest.json +21 -0
  2. README.md +13 -7
  3. app.py +91 -0
  4. requirements.txt +3 -0
.harp/manifest.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend_space": "REPLACE_WITH_YOUR_BACKEND_SPACE",
3
+ "deploy_mode": "remote-backend",
4
+ "entry": "app.py",
5
+ "framework": "gradio_client",
6
+ "generated": true,
7
+ "io": {
8
+ "inputs": [
9
+ "textbox",
10
+ "slider",
11
+ "number"
12
+ ],
13
+ "outputs": [
14
+ "audio"
15
+ ]
16
+ },
17
+ "repo_id": "SonyResearch/Woosh",
18
+ "source": "recipe",
19
+ "space_layout": "huggingface-gradio",
20
+ "task": "text-to-audio"
21
+ }
README.md CHANGED
@@ -1,13 +1,19 @@
1
  ---
2
- title: Woosh Dflow
3
- emoji: 🐠
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 6.19.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
1
  ---
2
+ title: "Woosh-DFlow (Text-to-Audio SFX)"
3
+ colorFrom: indigo
4
+ colorTo: gray
 
5
  sdk: gradio
6
+ sdk_version: 5.28.0
 
7
  app_file: app.py
8
  pinned: false
9
+ license: "cc-by-nc-4.0"
10
  ---
11
 
12
+ # Woosh-DFlow (Text-to-Audio SFX)
13
+
14
+ 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).
15
+
16
+ - Inputs: textbox, slider, number
17
+ - Outputs: audio
18
+
19
+ Generated by the HARP model agent from a recipe.
app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+
5
+ import gradio as gr
6
+
7
+ from pyharp import *
8
+ from gradio_client import Client, handle_file
9
+
10
+
11
+ _BACKEND_SPACE = "REPLACE_WITH_YOUR_BACKEND_SPACE"
12
+ _BACKEND_API_NAME = "/generate"
13
+ _BACKEND_TOKEN_ENV = "HF_TOKEN"
14
+ _ACCEPT_USER_TOKEN = False
15
+ _client = None
16
+
17
+
18
+ def _backend_client():
19
+ # Lazily create and cache one warm connection using this Space's own
20
+ # token (from the HF_TOKEN secret) or anonymous if none is set. User
21
+ # tokens are NOT cached here -- they get a fresh per-call connection.
22
+ global _client
23
+ if _client is None:
24
+ _token = os.environ.get(_BACKEND_TOKEN_ENV) or None
25
+ _client = Client(_BACKEND_SPACE, hf_token=_token)
26
+ return _client
27
+
28
+
29
+ def _quota_hint(message):
30
+ # Turn a backend ZeroGPU quota error into an actionable message.
31
+ # NOTE: 'message' is the backend's error text; it never contains our token.
32
+ _low = (message or "").lower()
33
+ if "quota" in _low or "zerogpu" in _low:
34
+ if _ACCEPT_USER_TOKEN:
35
+ return (
36
+ "The backend's ZeroGPU quota is exhausted for the identity making "
37
+ "this call. Paste your own Hugging Face token in the token field "
38
+ "(read scope) so usage is attributed to your account."
39
+ )
40
+ return (
41
+ "The backend's ZeroGPU quota is exhausted. This Space's calls are "
42
+ "anonymous unless an HF_TOKEN secret is set (Settings -> Variables "
43
+ "and secrets); use a token from a PRO account or a ZeroGPU-enabled org."
44
+ )
45
+ return message or "Backend call failed."
46
+
47
+
48
+ model_card = ModelCard(
49
+ name="Woosh-DFlow (Text-to-Audio SFX)",
50
+ 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).",
51
+ author="Sony AI (Hadjeres, Ferras, Koutini, Weck, Bittar, Hummel, Lahrichi, Missoum, Serra, Mitsufuji)",
52
+ tags=["text-to-audio", "sound-effects", "sfx", "generative-audio"],
53
+ )
54
+
55
+
56
+ def process_fn(prompt, cfg_scale, seed):
57
+ _conn = _backend_client()
58
+ try:
59
+ _raw = _conn.predict(
60
+ prompt,
61
+ float(cfg_scale),
62
+ int(seed),
63
+ api_name="/generate",
64
+ )
65
+ except Exception as _exc: # surface a token-aware hint, never the token
66
+ raise gr.Error(_quota_hint(str(_exc)))
67
+ _values = list(_raw) if isinstance(_raw, (list, tuple)) else [_raw]
68
+ _detail = " | ".join(str(_v) for _v in _values if isinstance(_v, str) and _v.strip())
69
+ _out_audio = _values[0] if len(_values) > 0 else None
70
+ if not _out_audio:
71
+ 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.")
72
+ return _out_audio
73
+
74
+
75
+ with gr.Blocks() as demo:
76
+ input_components = [
77
+ gr.Textbox(label="Prompt", info="Describe the sound effect to generate, e.g. 'sportscar engine revving and driving away quickly'."),
78
+ 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."),
79
+ gr.Number(value=-1, label="Seed", info="Random seed; use -1 for a new random result each run."),
80
+ ]
81
+ output_components = [
82
+ gr.Audio(type="filepath", label="Generated sound effect"),
83
+ ]
84
+ build_endpoint(
85
+ model_card=model_card,
86
+ input_components=input_components,
87
+ output_components=output_components,
88
+ process_fn=process_fn,
89
+ )
90
+
91
+ demo.queue().launch(share=True, show_error=False, pwa=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0
2
+ gradio>=4.0
3
+ gradio_client