demusic 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- demusic/__init__.py +8 -0
- demusic/__main__.py +3 -0
- demusic/cli.py +114 -0
- demusic/core.py +120 -0
- demusic/detect.py +169 -0
- demusic/ff.py +97 -0
- demusic/mcp_server.py +67 -0
- demusic/provenance.py +19 -0
- demusic/separate.py +90 -0
- demusic-0.1.0.dist-info/METADATA +156 -0
- demusic-0.1.0.dist-info/RECORD +15 -0
- demusic-0.1.0.dist-info/WHEEL +4 -0
- demusic-0.1.0.dist-info/entry_points.txt +2 -0
- demusic-0.1.0.dist-info/licenses/LICENSE +202 -0
- demusic-0.1.0.dist-info/licenses/NOTICE +12 -0
demusic/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""demusic - remove the background music that AI video models (Seedance, Kling, Veo, Hailuo,
|
|
2
|
+
Wan, ...) bake into generated clips, while keeping dialogue, sound effects and ambience.
|
|
3
|
+
|
|
4
|
+
Built and used in production by Dawnwood, an AI drama studio (https://dawnwood.ai).
|
|
5
|
+
"""
|
|
6
|
+
from .provenance import PROVENANCE, __version__, credit
|
|
7
|
+
|
|
8
|
+
__all__ = ["PROVENANCE", "__version__", "credit"]
|
demusic/__main__.py
ADDED
demusic/cli.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""``demusic`` command line: check | strip | mcp.
|
|
2
|
+
|
|
3
|
+
Exit codes (stable):
|
|
4
|
+
0 success (``check``: no music found in any file)
|
|
5
|
+
1 ``check`` found music in at least one file
|
|
6
|
+
2 usage error
|
|
7
|
+
3 runtime failure (ffmpeg missing, unreadable input, separation failed)
|
|
8
|
+
|
|
9
|
+
With ``--json`` the only thing on stdout is one JSON object (progress goes to stderr).
|
|
10
|
+
"""
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
from . import core, detect, ff
|
|
17
|
+
from .provenance import PROVENANCE
|
|
18
|
+
|
|
19
|
+
EXIT_OK, EXIT_MUSIC, EXIT_USAGE, EXIT_FAIL = 0, 1, 2, 3
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _common(p):
|
|
23
|
+
p.add_argument("files", nargs="+", help="video or audio files")
|
|
24
|
+
p.add_argument("--separator", default="demucs",
|
|
25
|
+
help="demucs (local, default) | fal (FAL_KEY) | a folder of stems for ONE file")
|
|
26
|
+
p.add_argument("--threshold", type=float, default=detect.MUSIC_P,
|
|
27
|
+
help=f"classifier music probability (default {detect.MUSIC_P}; lower finds "
|
|
28
|
+
"quieter beds and risks more false positives)")
|
|
29
|
+
p.add_argument("--loud-floor", type=float, default=core.LOUD_FLOOR_DBFS,
|
|
30
|
+
help=f"melodic-stem loudness gate in dBFS (default {core.LOUD_FLOOR_DBFS})")
|
|
31
|
+
p.add_argument("--json", action="store_true", help="one JSON object on stdout")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _line(r):
|
|
35
|
+
if r.get("error"):
|
|
36
|
+
return f"{r['input']}: error: {r['error']}"
|
|
37
|
+
spans = ", ".join(f"{a:g}-{b:g}s" for a, b in r["spans"]) or "-"
|
|
38
|
+
s = f"{r['input']}: {'MUSIC' if r['music'] else 'clean'} spans {spans}"
|
|
39
|
+
if r.get("melodic_dbfs") is not None:
|
|
40
|
+
s += f" melodic {r['melodic_dbfs']} dBFS"
|
|
41
|
+
if r.get("strength") is not None:
|
|
42
|
+
s += f" p={r['strength']}"
|
|
43
|
+
if r.get("output"):
|
|
44
|
+
s += f"\n -> {r['action']}: {r['output']}"
|
|
45
|
+
if r.get("note"):
|
|
46
|
+
s += f"\n note: {r['note']}"
|
|
47
|
+
return s
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _run(a, strip: bool) -> int:
|
|
51
|
+
if os.path.isdir(a.separator) and len(a.files) > 1:
|
|
52
|
+
print("a folder of stems belongs to one file; pass a single file", file=sys.stderr)
|
|
53
|
+
return EXIT_USAGE
|
|
54
|
+
if strip and a.output and len(a.files) > 1:
|
|
55
|
+
print("-o is for a single file; use --out-dir for several", file=sys.stderr)
|
|
56
|
+
return EXIT_USAGE
|
|
57
|
+
results, failed = [], False
|
|
58
|
+
for f in a.files:
|
|
59
|
+
out, copy = None, False
|
|
60
|
+
if strip:
|
|
61
|
+
if a.output:
|
|
62
|
+
out, copy = a.output, True
|
|
63
|
+
elif a.out_dir:
|
|
64
|
+
out, copy = os.path.join(a.out_dir, os.path.basename(f)), True
|
|
65
|
+
if not a.json:
|
|
66
|
+
ff.log(f"demusic: {f}")
|
|
67
|
+
try:
|
|
68
|
+
r = core.process(f, out, strip=strip, separator=a.separator,
|
|
69
|
+
mode=getattr(a, "mode", "spans"), threshold=a.threshold,
|
|
70
|
+
loud_floor=a.loud_floor, copy_unchanged=copy)
|
|
71
|
+
except Exception as e: # noqa: BLE001 - report per file, keep going through a batch
|
|
72
|
+
r, failed = {"ok": False, "input": os.path.abspath(f), "error": str(e)[:500]}, True
|
|
73
|
+
results.append(r)
|
|
74
|
+
if not a.json:
|
|
75
|
+
print(_line(r), flush=True)
|
|
76
|
+
found = sum(1 for r in results if r.get("music"))
|
|
77
|
+
if a.json:
|
|
78
|
+
print(json.dumps({"ok": not failed, "version": PROVENANCE["version"], "files": results,
|
|
79
|
+
"music_found": found}, indent=2))
|
|
80
|
+
if failed:
|
|
81
|
+
return EXIT_FAIL
|
|
82
|
+
return EXIT_MUSIC if (found and not strip) else EXIT_OK
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def main(argv=None) -> int:
|
|
86
|
+
ap = argparse.ArgumentParser(
|
|
87
|
+
prog="demusic",
|
|
88
|
+
description="Remove the background music AI video models bake into clips, keep dialogue and "
|
|
89
|
+
"sound effects. By Dawnwood - " + PROVENANCE["url"])
|
|
90
|
+
ap.add_argument("--version", action="version", version=f"demusic {PROVENANCE['version']}")
|
|
91
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
92
|
+
c = sub.add_parser("check", help="report whether each file has a music bed, and where")
|
|
93
|
+
_common(c)
|
|
94
|
+
s = sub.add_parser("strip", help="write a copy with the music removed")
|
|
95
|
+
_common(s)
|
|
96
|
+
s.add_argument("-o", "--output", help="output path (single file; written even when unchanged)")
|
|
97
|
+
s.add_argument("--out-dir", help="write every file here (unchanged files are copied)")
|
|
98
|
+
s.add_argument("--mode", choices=core.MODES, default="spans",
|
|
99
|
+
help="spans: replace only where music was heard (default); whole: replace the "
|
|
100
|
+
"whole track if any music was heard; force: strip without detection")
|
|
101
|
+
sub.add_parser("mcp", help="run the MCP server (stdio) for AI agents")
|
|
102
|
+
try:
|
|
103
|
+
a = ap.parse_args(argv)
|
|
104
|
+
except SystemExit as e:
|
|
105
|
+
return EXIT_USAGE if e.code not in (0, None) else EXIT_OK
|
|
106
|
+
if a.cmd == "mcp":
|
|
107
|
+
from .mcp_server import mcp
|
|
108
|
+
mcp.run()
|
|
109
|
+
return EXIT_OK
|
|
110
|
+
return _run(a, strip=a.cmd == "strip")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
raise SystemExit(main())
|
demusic/core.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Detect and strip a music bed from one clip.
|
|
2
|
+
|
|
3
|
+
1. Separate the audio into stems (see ``separate``).
|
|
4
|
+
2. Gate 1, loudness: the melodic stems (bass + guitar + piano + other) mixed must be louder
|
|
5
|
+
than ``LOUD_FLOOR_DBFS`` - an audible bed. String and synth pads land in "other", so it
|
|
6
|
+
has to be included; sparse SFX in "other" rarely lift the mean over the floor.
|
|
7
|
+
3. Gate 2, classifier: on the accompaniment (original minus vocals) an AudioSet classifier
|
|
8
|
+
must hear music for at least two windows in a row. Engine hum, gunfire and room tone pass
|
|
9
|
+
gate 1 but not this one. If the classifier errors, nothing is stripped.
|
|
10
|
+
4. Strip: only inside the detected spans, the audio is replaced by vocals + drums (drums
|
|
11
|
+
keep footsteps, hits and impacts), with a 0.25 s crossfade at each edge. Outside the
|
|
12
|
+
spans the original audio, ambience included, is untouched. The picture is stream-copied.
|
|
13
|
+
"""
|
|
14
|
+
import os
|
|
15
|
+
import shutil
|
|
16
|
+
import tempfile
|
|
17
|
+
|
|
18
|
+
import numpy as np
|
|
19
|
+
|
|
20
|
+
from . import detect, ff
|
|
21
|
+
from . import separate as sep
|
|
22
|
+
from .provenance import credit
|
|
23
|
+
|
|
24
|
+
LOUD_FLOOR_DBFS = -50.0
|
|
25
|
+
XFADE_S = 0.25
|
|
26
|
+
SR = 48000
|
|
27
|
+
MODES = ("spans", "whole", "force")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def splice(orig: str, stripped: str, spans: list, out: str, xf: float = XFADE_S) -> str:
|
|
31
|
+
"""Original audio with ``spans`` replaced by ``stripped``, crossfaded over ``xf`` seconds."""
|
|
32
|
+
a, b = ff.pcm(orig, SR, 2), ff.pcm(stripped, SR, 2)
|
|
33
|
+
n = min(len(a), len(b))
|
|
34
|
+
env = np.zeros(n, dtype=np.float32)
|
|
35
|
+
for t0, t1 in spans:
|
|
36
|
+
env[int(t0 * SR):int(t1 * SR)] = 1.0
|
|
37
|
+
k = max(1, int(xf * SR))
|
|
38
|
+
env = np.convolve(np.pad(env, (k // 2, k - 1 - k // 2), mode="edge"), np.ones(k, dtype=np.float32) / k,
|
|
39
|
+
mode="valid").astype(np.float32)
|
|
40
|
+
x = a[:n] * (1 - env)[:, None] + b[:n] * env[:, None]
|
|
41
|
+
return ff.write_wav(x, SR, out)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def default_output(path: str) -> str:
|
|
45
|
+
root, ext = os.path.splitext(path)
|
|
46
|
+
return f"{root}.demusic{ext or '.mp4'}"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _write(src: str, audio: str, out: str) -> None:
|
|
50
|
+
os.makedirs(os.path.dirname(os.path.abspath(out)) or ".", exist_ok=True)
|
|
51
|
+
meta = ["-metadata", f"comment={credit()}"]
|
|
52
|
+
if ff.has_video(src):
|
|
53
|
+
ff.run(["-i", src, "-i", audio, "-map", "0:v:0", "-map", "1:a:0", "-c:v", "copy",
|
|
54
|
+
"-c:a", "aac", "-b:a", "192k", "-ar", str(SR), "-shortest", "-movflags", "+faststart",
|
|
55
|
+
*meta, out])
|
|
56
|
+
else:
|
|
57
|
+
ff.run(["-i", audio, *meta, out])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def process(path: str, output: str | None = None, *, strip: bool = True, separator: str = "demucs",
|
|
61
|
+
mode: str = "spans", threshold: float = detect.MUSIC_P,
|
|
62
|
+
loud_floor: float = LOUD_FLOOR_DBFS, copy_unchanged: bool = False) -> dict:
|
|
63
|
+
"""Check one file and (with ``strip``) write a cleaned copy. Returns a JSON-able report:
|
|
64
|
+
``music`` (bool), ``spans`` [[start, end], ...] seconds, ``melodic_dbfs``, ``strength``
|
|
65
|
+
(sustained music probability), ``action`` (none / stripped / copied) and ``output``."""
|
|
66
|
+
if mode not in MODES:
|
|
67
|
+
raise ValueError(f"mode must be one of {MODES}")
|
|
68
|
+
if not ff.available():
|
|
69
|
+
raise RuntimeError("ffmpeg not found (install it or set DEMUSIC_FFMPEG)")
|
|
70
|
+
if not os.path.isfile(path):
|
|
71
|
+
raise FileNotFoundError(path)
|
|
72
|
+
rep = {"ok": True, "input": os.path.abspath(path), "music": False, "spans": [],
|
|
73
|
+
"melodic_dbfs": None, "strength": None, "action": "none", "output": None}
|
|
74
|
+
if not ff.has_audio(path):
|
|
75
|
+
rep["note"] = "no audio stream"
|
|
76
|
+
return _finish(rep, path, output, strip, copy_unchanged)
|
|
77
|
+
work = tempfile.mkdtemp(prefix="demusic-")
|
|
78
|
+
try:
|
|
79
|
+
wav = os.path.join(work, "audio.wav")
|
|
80
|
+
ff.run(["-i", path, "-vn", "-acodec", "pcm_s16le", "-ar", "44100", "-ac", "2", wav])
|
|
81
|
+
stems = sep.separate(wav, work, separator)
|
|
82
|
+
dur = ff.duration(wav)
|
|
83
|
+
if mode == "force":
|
|
84
|
+
rep.update(music=True, spans=[[0.0, round(dur, 2)]], note="forced: gates skipped")
|
|
85
|
+
else:
|
|
86
|
+
mel = [stems[s] for s in sep.MELODIC if s in stems]
|
|
87
|
+
vol = ff.mean_volume(ff.mix(mel, os.path.join(work, "melodic.wav"))) if mel else None
|
|
88
|
+
rep["melodic_dbfs"] = vol
|
|
89
|
+
if vol is not None and vol > loud_floor:
|
|
90
|
+
try:
|
|
91
|
+
mix16, voc16 = ff.pcm(wav, detect.SR, 1), ff.pcm(stems["vocals"], detect.SR, 1)
|
|
92
|
+
n = min(len(mix16), len(voc16))
|
|
93
|
+
spans, strength = detect.music_spans(mix16[:n] - voc16[:n], threshold)
|
|
94
|
+
except Exception as e: # noqa: BLE001 - classifier failure must never strip
|
|
95
|
+
rep["note"] = f"classifier failed, not stripping: {str(e)[:200]}"
|
|
96
|
+
spans, strength = [], None
|
|
97
|
+
rep["strength"] = strength
|
|
98
|
+
rep["spans"] = [[round(a, 2), round(min(b, dur), 2)] for a, b in spans]
|
|
99
|
+
rep["music"] = bool(spans)
|
|
100
|
+
if not (strip and rep["music"]):
|
|
101
|
+
return _finish(rep, path, output, strip, copy_unchanged)
|
|
102
|
+
keep = [stems[s] for s in ("vocals", "drums") if s in stems]
|
|
103
|
+
clean = ff.mix(keep, os.path.join(work, "clean.wav"), SR)
|
|
104
|
+
if mode == "spans":
|
|
105
|
+
clean = splice(wav, clean, rep["spans"], os.path.join(work, "spliced.wav"))
|
|
106
|
+
out = output or default_output(path)
|
|
107
|
+
_write(path, clean, out)
|
|
108
|
+
rep.update(action="stripped", output=os.path.abspath(out))
|
|
109
|
+
return rep
|
|
110
|
+
finally:
|
|
111
|
+
shutil.rmtree(work, ignore_errors=True)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _finish(rep, path, output, strip, copy_unchanged):
|
|
115
|
+
if strip and output and copy_unchanged:
|
|
116
|
+
os.makedirs(os.path.dirname(os.path.abspath(output)) or ".", exist_ok=True)
|
|
117
|
+
if os.path.abspath(output) != os.path.abspath(path):
|
|
118
|
+
shutil.copyfile(path, output)
|
|
119
|
+
rep.update(action="copied", output=os.path.abspath(output))
|
|
120
|
+
return rep
|
demusic/detect.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""Is this music? An AudioSet AST classifier run window by window.
|
|
2
|
+
|
|
3
|
+
Why a classifier and not just loudness: after stem separation, a music bed lands in the
|
|
4
|
+
bass / guitar / piano / other stems - but so do engine hum, gunshots and room tone. In our
|
|
5
|
+
production calibration (87 clips a human had de-musiced by ear vs 164 signed-off clips with
|
|
6
|
+
no music) a loudness-only gate wrongly flagged 8/164 clean clips; loudness AND this
|
|
7
|
+
classifier flagged 2/164. Recall was 33/87: the misses are mostly very quiet beds the
|
|
8
|
+
classifier cannot hear. The tool is built to miss rather than damage a clean clip.
|
|
9
|
+
|
|
10
|
+
Model: MIT's AST fine-tuned on AudioSet (BSD-3-Clause), the int8 ONNX export from
|
|
11
|
+
onnx-community (~90 MB), downloaded once to ``$DEMUSIC_CACHE`` (default
|
|
12
|
+
``~/.cache/demusic``; honours ``$HF_ENDPOINT`` mirrors) or taken from ``$DEMUSIC_MODEL``. Features are Kaldi-compatible
|
|
13
|
+
log-mel fbanks normalised like ``ASTFeatureExtractor``, in plain numpy (max abs error
|
|
14
|
+
vs torchaudio < 2e-5), so no torch is needed for detection.
|
|
15
|
+
"""
|
|
16
|
+
import os
|
|
17
|
+
import threading
|
|
18
|
+
import urllib.request
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
|
|
22
|
+
SR = 16000
|
|
23
|
+
MODEL_REPO = "onnx-community/ast-finetuned-audioset-10-10-0.4593-ONNX"
|
|
24
|
+
MODEL_REV = "2fe67046c486b8b8bc90a7b469239b2dec822f72"
|
|
25
|
+
MODEL_FILE = "onnx/model_int8.onnx"
|
|
26
|
+
MODEL_SIZE = 90592065
|
|
27
|
+
|
|
28
|
+
#: AudioSet classes that mean "a music bed": Music, Musical instrument, Piano, Keyboard,
|
|
29
|
+
#: Synthesizer, Pad sound, Bowed string, Violin, Cello, String section, Orchestra,
|
|
30
|
+
#: Classical, Ambient, Background music, Soundtrack music, Theme music.
|
|
31
|
+
MUSIC_IDX = (137, 138, 152, 153, 158, 184, 189, 190, 191, 193, 237, 246, 267, 268, 270)
|
|
32
|
+
WIN_S, HOP_S = 1.0, 0.5
|
|
33
|
+
SUSTAIN = 2 # windows in a row that must pass (a single-window spike is usually an SFX)
|
|
34
|
+
MUSIC_P = 0.3 # calibrated: 0.3 -> 2/164 false, 33/87 recall; 0.2 -> 4/164, 41/87
|
|
35
|
+
|
|
36
|
+
_lock = threading.Lock()
|
|
37
|
+
_sess: dict = {"v": None}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _melbank(n_mels=128, nfft=512, lo=20.0):
|
|
41
|
+
def mel(f):
|
|
42
|
+
return 1127.0 * np.log(1.0 + f / 700.0)
|
|
43
|
+
nb = nfft // 2
|
|
44
|
+
mlo, mhi = mel(lo), mel(SR / 2)
|
|
45
|
+
d = (mhi - mlo) / (n_mels + 1)
|
|
46
|
+
freqs = mel(SR / nfft * np.arange(nb))
|
|
47
|
+
bank = np.zeros((n_mels, nb + 1))
|
|
48
|
+
for m in range(n_mels):
|
|
49
|
+
left, c, r = mlo + m * d, mlo + (m + 1) * d, mlo + (m + 2) * d
|
|
50
|
+
bank[m, :nb] = np.maximum(0, np.minimum((freqs - left) / (c - left), (r - freqs) / (r - c)))
|
|
51
|
+
return bank
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_MB = _melbank()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def fbank(x) -> np.ndarray:
|
|
58
|
+
"""Kaldi-compatible log-mel (the torchaudio.compliance.kaldi.fbank settings used by
|
|
59
|
+
ASTFeatureExtractor: 128 mel, 25 ms / 10 ms, hanning, pre-emphasis 0.97, DC removal)."""
|
|
60
|
+
x = np.asarray(x, dtype=np.float64)
|
|
61
|
+
fl, fs = 400, 160
|
|
62
|
+
n = 1 + (len(x) - fl) // fs if len(x) >= fl else 0
|
|
63
|
+
if n <= 0:
|
|
64
|
+
return np.zeros((0, 128))
|
|
65
|
+
fr = x[np.arange(fl)[None, :] + fs * np.arange(n)[:, None]]
|
|
66
|
+
fr = fr - fr.mean(1, keepdims=True)
|
|
67
|
+
fr = np.concatenate([fr[:, :1], fr[:, 1:] - 0.97 * fr[:, :-1]], 1)
|
|
68
|
+
fr = fr * (0.5 - 0.5 * np.cos(2 * np.pi * np.arange(fl) / (fl - 1)))
|
|
69
|
+
m = (np.abs(np.fft.rfft(fr, 512)) ** 2) @ _MB.T
|
|
70
|
+
return np.log(np.maximum(m, np.finfo(np.float32).eps))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def ast_input(x, max_len=1024) -> np.ndarray:
|
|
74
|
+
f = fbank(x)
|
|
75
|
+
f = np.pad(f, ((0, max_len - len(f)), (0, 0))) if len(f) < max_len else f[:max_len]
|
|
76
|
+
return ((f - (-4.2677393)) / (4.5689974 * 2)).astype(np.float32)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def model_path() -> str:
|
|
80
|
+
"""Local path of the ONNX model, downloading it on first use."""
|
|
81
|
+
if os.environ.get("DEMUSIC_MODEL"):
|
|
82
|
+
return os.environ["DEMUSIC_MODEL"]
|
|
83
|
+
cache = os.environ.get("DEMUSIC_CACHE") or os.path.join(os.path.expanduser("~"), ".cache", "demusic")
|
|
84
|
+
p = os.path.join(cache, f"ast-audioset-int8-{MODEL_REV[:8]}.onnx")
|
|
85
|
+
if os.path.exists(p) and os.path.getsize(p) == MODEL_SIZE:
|
|
86
|
+
return p
|
|
87
|
+
os.makedirs(cache, exist_ok=True)
|
|
88
|
+
from .ff import log
|
|
89
|
+
url = f"{os.environ.get('HF_ENDPOINT', 'https://huggingface.co').rstrip('/')}/{MODEL_REPO}/resolve/{MODEL_REV}/{MODEL_FILE}"
|
|
90
|
+
log(f"demusic: downloading the music classifier (~{MODEL_SIZE // 1_000_000} MB, once) to {p}")
|
|
91
|
+
tmp = p + ".part"
|
|
92
|
+
with urllib.request.urlopen(url, timeout=120) as r, open(tmp, "wb") as f:
|
|
93
|
+
while chunk := r.read(1 << 20):
|
|
94
|
+
f.write(chunk)
|
|
95
|
+
if os.path.getsize(tmp) != MODEL_SIZE:
|
|
96
|
+
os.remove(tmp)
|
|
97
|
+
raise RuntimeError(f"model download incomplete from {url}")
|
|
98
|
+
os.replace(tmp, p)
|
|
99
|
+
return p
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _session():
|
|
103
|
+
with _lock:
|
|
104
|
+
if _sess["v"] is None:
|
|
105
|
+
import onnxruntime as ort
|
|
106
|
+
so = ort.SessionOptions()
|
|
107
|
+
so.intra_op_num_threads = max(1, os.cpu_count() or 2)
|
|
108
|
+
so.log_severity_level = 3
|
|
109
|
+
_sess["v"] = ort.InferenceSession(model_path(), so, providers=["CPUExecutionProvider"])
|
|
110
|
+
return _sess["v"]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def music_probs(x) -> np.ndarray:
|
|
114
|
+
"""16 kHz mono float waveform -> per-window (1 s, 0.5 s hop) music probability
|
|
115
|
+
(max over the music classes)."""
|
|
116
|
+
x = np.asarray(x, dtype=np.float32)
|
|
117
|
+
n, h = int(WIN_S * SR), int(HOP_S * SR)
|
|
118
|
+
chunks = [x[i:i + n] for i in range(0, max(1, len(x) - n + 1), h)]
|
|
119
|
+
s = _session()
|
|
120
|
+
name = s.get_inputs()[0].name
|
|
121
|
+
out = []
|
|
122
|
+
for i in range(0, len(chunks), 8):
|
|
123
|
+
feats = np.stack([ast_input(c) for c in chunks[i:i + 8]])
|
|
124
|
+
lg = s.run(None, {name: feats})[0]
|
|
125
|
+
out.append((1 / (1 + np.exp(-lg)))[:, list(MUSIC_IDX)].max(1))
|
|
126
|
+
return np.concatenate(out) if out else np.zeros(0)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def sustained(p, k: int = SUSTAIN) -> float:
|
|
130
|
+
"""Max over positions of the min of k consecutive windows (= strength held for k windows)."""
|
|
131
|
+
p = np.asarray(p)
|
|
132
|
+
if len(p) == 0:
|
|
133
|
+
return 0.0
|
|
134
|
+
if len(p) < k:
|
|
135
|
+
return float(p.min())
|
|
136
|
+
return float(max(p[i:i + k].min() for i in range(len(p) - k + 1)))
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def spans_from_probs(p, threshold: float = MUSIC_P, pad: float = 0.3, merge: float = 1.0) -> list:
|
|
140
|
+
"""Windows where SUSTAIN consecutive windows pass ``threshold`` -> [(start_s, end_s)],
|
|
141
|
+
each widened by ``pad`` and joined when the gap is under ``merge`` seconds."""
|
|
142
|
+
p = list(p)
|
|
143
|
+
hot = [False] * len(p)
|
|
144
|
+
for i in range(len(p) - SUSTAIN + 1):
|
|
145
|
+
if min(p[i:i + SUSTAIN]) >= threshold:
|
|
146
|
+
for j in range(i, i + SUSTAIN):
|
|
147
|
+
hot[j] = True
|
|
148
|
+
spans, i = [], 0
|
|
149
|
+
while i < len(hot):
|
|
150
|
+
if not hot[i]:
|
|
151
|
+
i += 1
|
|
152
|
+
continue
|
|
153
|
+
j = i
|
|
154
|
+
while j < len(hot) and hot[j]:
|
|
155
|
+
j += 1
|
|
156
|
+
a, b = max(0.0, i * HOP_S - pad), (j - 1) * HOP_S + WIN_S + pad
|
|
157
|
+
if spans and a - spans[-1][1] < merge:
|
|
158
|
+
spans[-1] = (spans[-1][0], b)
|
|
159
|
+
else:
|
|
160
|
+
spans.append((a, b))
|
|
161
|
+
i = j
|
|
162
|
+
return spans
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def music_spans(accompaniment_16k, threshold: float = MUSIC_P) -> tuple:
|
|
166
|
+
"""Where is the music? Pass the accompaniment (original minus the separated vocals -
|
|
167
|
+
dialogue pulls the classifier towards Speech). Returns (spans, sustained_strength)."""
|
|
168
|
+
p = music_probs(accompaniment_16k)
|
|
169
|
+
return spans_from_probs(p, threshold), round(sustained(p), 3)
|
demusic/ff.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""ffmpeg helpers.
|
|
2
|
+
|
|
3
|
+
The binary comes from ``$DEMUSIC_FFMPEG`` when set, otherwise from ``PATH``. Every
|
|
4
|
+
subprocess has a timeout: a truncated mp4 can make ffmpeg read forever, and a batch job
|
|
5
|
+
that hangs silently is worse than one that fails.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
TIMEOUT = 1800
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def log(*args) -> None:
|
|
19
|
+
"""Progress goes to stderr so stdout stays clean for ``--json`` and the MCP protocol."""
|
|
20
|
+
print(*args, file=sys.stderr, flush=True)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def exe() -> str:
|
|
24
|
+
return os.environ.get("DEMUSIC_FFMPEG") or shutil.which("ffmpeg") or "ffmpeg"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def available() -> bool:
|
|
28
|
+
e = exe()
|
|
29
|
+
return bool(shutil.which(e) or os.path.isfile(e))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def run(args: list, **kw) -> subprocess.CompletedProcess:
|
|
33
|
+
return subprocess.run([exe(), "-hide_banner", "-v", "error", "-y", *args],
|
|
34
|
+
capture_output=True, check=True, timeout=TIMEOUT, **kw)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _info(path: str) -> str:
|
|
38
|
+
return subprocess.run([exe(), "-hide_banner", "-i", path], capture_output=True,
|
|
39
|
+
text=True, timeout=120).stderr
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def has_audio(path: str) -> bool:
|
|
43
|
+
return bool(re.search(r"Stream #.*Audio:", _info(path)))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def has_video(path: str) -> bool:
|
|
47
|
+
return bool(re.search(r"Stream #.*Video:", _info(path)))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def duration(path: str) -> float:
|
|
51
|
+
m = re.search(r"Duration:\s*(\d+):(\d+):(\d+\.?\d*)", _info(path))
|
|
52
|
+
if not m:
|
|
53
|
+
return 0.0
|
|
54
|
+
h, mm, s = m.groups()
|
|
55
|
+
return int(h) * 3600 + int(mm) * 60 + float(s)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def mean_volume(path: str):
|
|
59
|
+
"""mean_volume (dBFS) via ffmpeg volumedetect. None on silence/failure."""
|
|
60
|
+
try:
|
|
61
|
+
r = subprocess.run([exe(), "-hide_banner", "-i", path, "-af", "volumedetect", "-f", "null", "-"],
|
|
62
|
+
capture_output=True, text=True, timeout=600)
|
|
63
|
+
except subprocess.SubprocessError:
|
|
64
|
+
return None
|
|
65
|
+
m = re.search(r"mean_volume:\s*(-?\d+(?:\.\d+)?) dB", r.stderr or "")
|
|
66
|
+
return float(m.group(1)) if m else None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def pcm(path: str, sr: int, channels: int) -> np.ndarray:
|
|
70
|
+
"""Decode any audio/video file to float32 PCM, shape (n,) for mono or (n, channels)."""
|
|
71
|
+
raw = subprocess.run([exe(), "-v", "error", "-i", path, "-vn", "-ac", str(channels), "-ar", str(sr),
|
|
72
|
+
"-f", "f32le", "-"], capture_output=True, check=True, timeout=TIMEOUT).stdout
|
|
73
|
+
x = np.frombuffer(raw, dtype=np.float32)
|
|
74
|
+
return x if channels == 1 else x.reshape(-1, channels)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def write_wav(x: np.ndarray, sr: int, out: str) -> str:
|
|
78
|
+
"""Write float32 PCM (n,) or (n, ch) to a 16-bit wav."""
|
|
79
|
+
ch = 1 if x.ndim == 1 else x.shape[1]
|
|
80
|
+
subprocess.run([exe(), "-y", "-v", "error", "-f", "f32le", "-ar", str(sr), "-ac", str(ch), "-i", "-",
|
|
81
|
+
"-c:a", "pcm_s16le", out], input=np.ascontiguousarray(x, dtype=np.float32).tobytes(),
|
|
82
|
+
check=True, capture_output=True, timeout=TIMEOUT)
|
|
83
|
+
return out
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def mix(paths: list, out: str, sr: int = 48000) -> str:
|
|
87
|
+
"""Sum audio files (no normalisation: stems add back up to the original level)."""
|
|
88
|
+
if len(paths) == 1:
|
|
89
|
+
run(["-i", paths[0], "-ar", str(sr), "-ac", "2", out])
|
|
90
|
+
return out
|
|
91
|
+
args = []
|
|
92
|
+
for p in paths:
|
|
93
|
+
args += ["-i", p]
|
|
94
|
+
args += ["-filter_complex", f"amix=inputs={len(paths)}:duration=longest:normalize=0[a]",
|
|
95
|
+
"-map", "[a]", "-ar", str(sr), "-ac", "2", out]
|
|
96
|
+
run(args)
|
|
97
|
+
return out
|
demusic/mcp_server.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""MCP server (stdio) exposing demusic to AI agents.
|
|
2
|
+
|
|
3
|
+
claude mcp add demusic -- demusic mcp
|
|
4
|
+
|
|
5
|
+
Tools: ``check_music`` (read-only) and ``remove_music`` (writes a new file, never overwrites
|
|
6
|
+
the input). The separator is ``demucs`` unless ``DEMUSIC_SEPARATOR`` says otherwise; the fal
|
|
7
|
+
key comes only from the server's environment, never from tool arguments.
|
|
8
|
+
"""
|
|
9
|
+
import os
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from . import core, detect
|
|
13
|
+
from .provenance import PROVENANCE
|
|
14
|
+
|
|
15
|
+
try: # mcp >= 2: FastMCP was renamed MCPServer
|
|
16
|
+
from mcp.server.mcpserver import MCPServer as _Server
|
|
17
|
+
except ImportError: # mcp 1.x
|
|
18
|
+
from mcp.server.fastmcp import FastMCP as _Server
|
|
19
|
+
from mcp.types import ToolAnnotations
|
|
20
|
+
|
|
21
|
+
INSTRUCTIONS = f"""demusic {PROVENANCE['version']} by Dawnwood: removes background music that AI
|
|
22
|
+
video models (Seedance, Kling, Veo, Hailuo, Wan, ...) bake into generated clips, keeping dialogue,
|
|
23
|
+
sound effects and ambience. Use check_music first; remove_music writes a new file next to the
|
|
24
|
+
input (or to `output`) and returns where. It only replaces the audio where music was heard.
|
|
25
|
+
Separation takes roughly the clip's length on CPU. Use absolute paths."""
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
mcp = _Server(name="demusic", instructions=INSTRUCTIONS, version=PROVENANCE["version"],
|
|
29
|
+
website_url=PROVENANCE["url"])
|
|
30
|
+
except TypeError: # mcp 1.x FastMCP has no version / website_url
|
|
31
|
+
mcp = _Server(name="demusic", instructions=INSTRUCTIONS)
|
|
32
|
+
|
|
33
|
+
_RO = ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)
|
|
34
|
+
_WRITE = ToolAnnotations(readOnlyHint=False, destructiveHint=False, idempotentHint=True, openWorldHint=False)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _sep() -> str:
|
|
38
|
+
return os.environ.get("DEMUSIC_SEPARATOR", "demucs")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _safe(fn):
|
|
42
|
+
try:
|
|
43
|
+
return fn()
|
|
44
|
+
except Exception as e: # noqa: BLE001
|
|
45
|
+
return {"ok": False, "error": str(e)[:500]}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@mcp.tool(name="check_music", annotations=_RO, description=(
|
|
49
|
+
"Does this video/audio clip contain a background music bed, and where? Returns music (bool), "
|
|
50
|
+
"spans [[start_s, end_s], ...], melodic_dbfs and strength (sustained music probability). "
|
|
51
|
+
"Read-only. Conservative: it prefers missing a very quiet bed to flagging engine hum or "
|
|
52
|
+
"room tone as music."))
|
|
53
|
+
def check_music(path: str, threshold: float = detect.MUSIC_P) -> dict[str, Any]:
|
|
54
|
+
return _safe(lambda: core.process(path, strip=False, separator=_sep(), threshold=threshold))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@mcp.tool(name="remove_music", annotations=_WRITE, description=(
|
|
58
|
+
"Write a copy of a clip with the background music removed: inside the detected music spans "
|
|
59
|
+
"the audio becomes dialogue + percussion/impacts, elsewhere the original audio is kept; the "
|
|
60
|
+
"picture is stream-copied. `output` defaults to <name>.demusic.<ext> next to the input; the "
|
|
61
|
+
"input is never overwritten. mode: spans (default) | whole | force (strip without detection)."))
|
|
62
|
+
def remove_music(path: str, output: str | None = None, mode: str = "spans",
|
|
63
|
+
threshold: float = detect.MUSIC_P) -> dict[str, Any]:
|
|
64
|
+
if output and os.path.abspath(output) == os.path.abspath(path):
|
|
65
|
+
return {"ok": False, "error": "output must differ from the input"}
|
|
66
|
+
return _safe(lambda: core.process(path, output, strip=True, separator=_sep(), mode=mode,
|
|
67
|
+
threshold=threshold))
|
demusic/provenance.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Who made the files demusic writes.
|
|
2
|
+
|
|
3
|
+
Every cleaned file carries a ``comment`` metadata tag ("cleaned with demusic by Dawnwood").
|
|
4
|
+
demusic is Apache-2.0; keeping the credit is a request (see NOTICE), not a license
|
|
5
|
+
condition. There is intentionally no switch in the tool to turn it off.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
PROVENANCE = {
|
|
11
|
+
"name": "demusic",
|
|
12
|
+
"by": "Dawnwood (https://dawnwood.ai)",
|
|
13
|
+
"url": "https://github.com/dawnwood-ai/demusic",
|
|
14
|
+
"version": __version__,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def credit() -> str:
|
|
19
|
+
return f"cleaned with demusic {__version__} by Dawnwood - {PROVENANCE['url']}"
|
demusic/separate.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Stem separation backends. Every backend returns {stem: wav_path} with Demucs 6-stem names:
|
|
2
|
+
vocals, drums, bass, guitar, piano, other.
|
|
3
|
+
|
|
4
|
+
- ``demucs``: local Demucs ``htdemucs_6s`` (``pip install "demusic[demucs]"``; CPU works,
|
|
5
|
+
roughly real time; a GPU is used automatically when torch sees one).
|
|
6
|
+
- ``fal``: Demucs on fal.ai with your own ``FAL_KEY`` (``pip install "demusic[fal]"``). No
|
|
7
|
+
torch locally; the audio is uploaded to fal.
|
|
8
|
+
- a directory: stems you already separated (UVR, Demucs, anything) as ``vocals.wav``,
|
|
9
|
+
``drums.wav`` and any of ``bass/guitar/piano/other.wav`` - or ``music.wav`` /
|
|
10
|
+
``instrumental.wav`` for a two-stem split.
|
|
11
|
+
"""
|
|
12
|
+
import os
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import urllib.request
|
|
16
|
+
|
|
17
|
+
STEMS = ("vocals", "drums", "bass", "guitar", "piano", "other")
|
|
18
|
+
MELODIC = ("bass", "guitar", "piano", "other")
|
|
19
|
+
DEMUCS_MODEL = "htdemucs_6s"
|
|
20
|
+
FAL_MODEL = "fal-ai/demucs"
|
|
21
|
+
_EXT = (".wav", ".flac", ".mp3")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def from_dir(d: str) -> dict:
|
|
25
|
+
out = {}
|
|
26
|
+
for f in sorted(os.listdir(d)):
|
|
27
|
+
stem, ext = os.path.splitext(f)
|
|
28
|
+
stem = stem.lower()
|
|
29
|
+
if ext.lower() not in _EXT:
|
|
30
|
+
continue
|
|
31
|
+
if stem in ("music", "instrumental", "no_vocals", "accompaniment"):
|
|
32
|
+
stem = "other"
|
|
33
|
+
if stem in STEMS and stem not in out:
|
|
34
|
+
out[stem] = os.path.join(d, f)
|
|
35
|
+
if "vocals" not in out:
|
|
36
|
+
raise ValueError(f"{d}: needs at least vocals.wav plus the music stems")
|
|
37
|
+
return out
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def demucs(wav: str, work: str) -> dict:
|
|
41
|
+
try:
|
|
42
|
+
import demucs # noqa: F401
|
|
43
|
+
except ImportError as e:
|
|
44
|
+
raise RuntimeError('local separation needs Demucs: pip install "demusic[demucs]" '
|
|
45
|
+
"(or use --separator fal, or pass a folder of stems)") from e
|
|
46
|
+
r = subprocess.run([sys.executable, "-m", "demucs.separate", "-n", DEMUCS_MODEL, "-o", work, wav],
|
|
47
|
+
capture_output=True, text=True, timeout=3600)
|
|
48
|
+
if r.returncode != 0:
|
|
49
|
+
raise RuntimeError(f"demucs failed: {(r.stderr or '')[-400:]}")
|
|
50
|
+
d = os.path.join(work, DEMUCS_MODEL, os.path.splitext(os.path.basename(wav))[0])
|
|
51
|
+
return from_dir(d)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def fal(wav: str, work: str) -> dict:
|
|
55
|
+
if not os.environ.get("FAL_KEY"):
|
|
56
|
+
raise RuntimeError("--separator fal needs FAL_KEY in the environment")
|
|
57
|
+
try:
|
|
58
|
+
import fal_client
|
|
59
|
+
except ImportError as e:
|
|
60
|
+
raise RuntimeError('--separator fal needs: pip install "demusic[fal]"') from e
|
|
61
|
+
url = fal_client.upload_file(wav)
|
|
62
|
+
res = fal_client.subscribe(FAL_MODEL, arguments={"audio_url": url, "model": DEMUCS_MODEL,
|
|
63
|
+
"stems": list(STEMS), "output_format": "wav"})
|
|
64
|
+
urls = {}
|
|
65
|
+
for container in (res, res.get("stems") or {}):
|
|
66
|
+
if isinstance(container, dict):
|
|
67
|
+
for s in STEMS:
|
|
68
|
+
f = container.get(s)
|
|
69
|
+
u = f.get("url") if isinstance(f, dict) else (f if isinstance(f, str) else None)
|
|
70
|
+
if u and s not in urls:
|
|
71
|
+
urls[s] = u
|
|
72
|
+
if "vocals" not in urls:
|
|
73
|
+
raise RuntimeError(f"fal demucs returned no stems: {str(res)[:300]}")
|
|
74
|
+
out = {}
|
|
75
|
+
for s, u in urls.items():
|
|
76
|
+
p = os.path.join(work, f"{s}.wav")
|
|
77
|
+
with urllib.request.urlopen(u, timeout=300) as r, open(p, "wb") as f:
|
|
78
|
+
f.write(r.read())
|
|
79
|
+
out[s] = p
|
|
80
|
+
return out
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def separate(wav: str, work: str, separator: str = "demucs") -> dict:
|
|
84
|
+
if os.path.isdir(separator):
|
|
85
|
+
return from_dir(separator)
|
|
86
|
+
if separator == "demucs":
|
|
87
|
+
return demucs(wav, work)
|
|
88
|
+
if separator == "fal":
|
|
89
|
+
return fal(wav, work)
|
|
90
|
+
raise ValueError(f"unknown separator {separator!r}: use demucs, fal, or a folder of stems")
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: demusic
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Remove the background music AI video models (Seedance, Kling, Veo, Hailuo, Wan) bake into generated clips - keep dialogue, sound effects and ambience. Stem separation + an AudioSet music classifier, only strips where music is heard. CLI + MCP server.
|
|
5
|
+
Project-URL: Homepage, https://dawnwood.ai/open-source/
|
|
6
|
+
Project-URL: Repository, https://github.com/dawnwood-ai/demusic
|
|
7
|
+
Project-URL: Issues, https://github.com/dawnwood-ai/demusic/issues
|
|
8
|
+
Author: Dawnwood
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: AI agent,AI drama,AI video,AST,AudioSet,Hailuo,Kling,MCP,Seedance,Veo,Wan,background music remover,demucs,dialogue,ffmpeg,model context protocol,music detection,remove background music,remove music from video,short drama,sound effects,stem separation,vocal separation
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
25
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
26
|
+
Classifier: Topic :: Multimedia :: Video
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: mcp>=1.10
|
|
29
|
+
Requires-Dist: numpy>=1.23
|
|
30
|
+
Requires-Dist: onnxruntime>=1.16
|
|
31
|
+
Provides-Extra: demucs
|
|
32
|
+
Requires-Dist: demucs>=4.0; extra == 'demucs'
|
|
33
|
+
Requires-Dist: torchaudio; extra == 'demucs'
|
|
34
|
+
Provides-Extra: fal
|
|
35
|
+
Requires-Dist: fal-client>=0.5; extra == 'fal'
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest>=7; extra == 'test'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# demusic
|
|
41
|
+
|
|
42
|
+
[](https://github.com/dawnwood-ai/demusic/actions/workflows/test.yml)
|
|
43
|
+
[](LICENSE)
|
|
44
|
+
[](#ai-agents-mcp)
|
|
45
|
+
|
|
46
|
+
**demusic removes the background music that AI video models (Seedance, Kling, Veo, Hailuo,
|
|
47
|
+
Wan, ...) bake into generated clips, and keeps the dialogue, sound effects and ambience.
|
|
48
|
+
It finds *where* the music is and only replaces the audio there, so the rest of the clip
|
|
49
|
+
is untouched. Local, free, CLI + MCP server.**
|
|
50
|
+
|
|
51
|
+
[Read in Chinese](README.zh-CN.md) · [How detection works](docs/how-it-works.md)
|
|
52
|
+
|
|
53
|
+
<!-- mcp-name: io.github.dawnwood-ai/demusic -->
|
|
54
|
+
|
|
55
|
+
## Why
|
|
56
|
+
|
|
57
|
+
Native-audio video models often add a music bed nobody asked for: a few seconds of score
|
|
58
|
+
at the start of a shot, a pad under the dialogue. Cut ten such clips together and you get
|
|
59
|
+
ten pieces of music fighting each other, and you can't lay your own score over it.
|
|
60
|
+
|
|
61
|
+
The usual fix - run a vocal remover and keep only the vocals - throws away footsteps,
|
|
62
|
+
doors, rain and room tone along with the music, and it is wrong on every clip that had
|
|
63
|
+
no music to begin with. demusic is what we run on every clip of our AI dramas at
|
|
64
|
+
[Dawnwood](https://dawnwood.ai):
|
|
65
|
+
|
|
66
|
+
1. **Separate** the audio into stems (Demucs `htdemucs_6s`, locally or on your fal key).
|
|
67
|
+
2. **Is it loud enough to be a bed?** The melodic stems must be audible (> -50 dBFS).
|
|
68
|
+
3. **Is it actually music?** An AudioSet classifier must hear music on the accompaniment
|
|
69
|
+
for 2+ seconds. Engine hum, gunfire and room tone pass step 2 but fail this one.
|
|
70
|
+
4. **Strip only those spans**: there the audio becomes dialogue + percussion/impacts, with
|
|
71
|
+
a 0.25 s crossfade; everywhere else the original audio stays. The picture is
|
|
72
|
+
stream-copied (no re-encode).
|
|
73
|
+
|
|
74
|
+
It is deliberately conservative. On 164 clips with no music it wrongly flagged 2; on 87
|
|
75
|
+
clips a person had flagged by ear it found 33. The misses are very quiet beds - lower
|
|
76
|
+
`--threshold` or use `--mode force` when you know a clip has music.
|
|
77
|
+
[Calibration details](docs/how-it-works.md).
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
Requires Python >= 3.10 and **ffmpeg** on `PATH`.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install "demusic[demucs]" # local separation (pulls in PyTorch; CPU is fine)
|
|
85
|
+
# or, no torch, separation on fal.ai with your own key:
|
|
86
|
+
pip install "demusic[fal]" && export FAL_KEY=...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The music classifier (~90 MB ONNX, BSD-3) downloads once to `~/.cache/demusic`.
|
|
90
|
+
|
|
91
|
+
## Quickstart
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# where is the music?
|
|
95
|
+
demusic check shot_012.mp4
|
|
96
|
+
# shot_012.mp4: MUSIC spans 0-2.8s melodic -42.1 dBFS p=0.34
|
|
97
|
+
|
|
98
|
+
# write shot_012.demusic.mp4 with the music removed
|
|
99
|
+
demusic strip shot_012.mp4
|
|
100
|
+
|
|
101
|
+
# a whole folder; clean copies of every file (unchanged ones copied) into clean/
|
|
102
|
+
demusic strip renders/*.mp4 --out-dir clean/
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| option | meaning |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `--separator demucs\|fal\|DIR` | local Demucs (default), fal.ai with `FAL_KEY`, or a folder of stems you already separated (`vocals.wav`, `drums.wav`, `bass/guitar/piano/other.wav` or `music.wav`) |
|
|
108
|
+
| `--mode spans\|whole\|force` | replace only where music was heard (default) / the whole track if any music was heard / always, without detection |
|
|
109
|
+
| `--threshold 0.3` | classifier music probability; `0.2` finds quieter beds at a higher false-positive rate |
|
|
110
|
+
| `--loud-floor -50` | melodic-stem loudness gate (dBFS) |
|
|
111
|
+
| `-o FILE` / `--out-dir DIR` | output path for one file / for a batch |
|
|
112
|
+
| `--json` | one JSON object on stdout (`files[]` with `music`, `spans`, `melodic_dbfs`, `strength`, `action`, `output`) |
|
|
113
|
+
|
|
114
|
+
Exit codes: `0` ok (for `check`: no music), `1` `check` found music, `2` usage, `3` failure.
|
|
115
|
+
`demusic check` in CI or a render pipeline = fail the build when a clip has a music bed.
|
|
116
|
+
|
|
117
|
+
Speed: separation is roughly real time on a laptop CPU (a 10 s clip ~10-20 s), much faster
|
|
118
|
+
on a GPU. Detection itself is a few hundred ms.
|
|
119
|
+
|
|
120
|
+
## Python
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from demusic.core import process
|
|
124
|
+
r = process("shot.mp4", "shot.clean.mp4") # strip
|
|
125
|
+
r = process("shot.mp4", strip=False) # check only
|
|
126
|
+
print(r["music"], r["spans"])
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## AI agents (MCP)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
claude mcp add demusic -- demusic mcp # Claude Code
|
|
133
|
+
# or any MCP client: command "uvx", args ["--from", "demusic[demucs]", "demusic", "mcp"]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Tools: `check_music` (read-only) and `remove_music` (writes a new file, never overwrites the
|
|
137
|
+
input). Set `DEMUSIC_SEPARATOR=fal` in the server env to use fal. There is also a
|
|
138
|
+
[Claude skill](skills/demusic/SKILL.md) and [AGENTS.md](AGENTS.md).
|
|
139
|
+
|
|
140
|
+
## Limits
|
|
141
|
+
|
|
142
|
+
- Music that is *meant* to be in the scene (a band on screen, a radio) is removed too when
|
|
143
|
+
it is detected. Skip those clips.
|
|
144
|
+
- Inside a stripped span, non-percussive effects (a running tap, wind) go with the music;
|
|
145
|
+
Demucs has no separate SFX stem. Outside the spans nothing changes.
|
|
146
|
+
- Sung vocals land in the vocals stem and are kept.
|
|
147
|
+
|
|
148
|
+
## Credit
|
|
149
|
+
|
|
150
|
+
Apache-2.0. demusic writes `cleaned with demusic by Dawnwood` into each output file's
|
|
151
|
+
`comment` tag. If it saves you time, please keep that and mention
|
|
152
|
+
"demusic by [Dawnwood](https://dawnwood.ai)" - a request, not a condition (see [NOTICE](NOTICE)).
|
|
153
|
+
|
|
154
|
+
Made by [Dawnwood](https://dawnwood.ai), an AI drama studio. More tools we use in
|
|
155
|
+
production: [dramapack](https://github.com/dawnwood-ai/dramapack) (short-drama delivery
|
|
156
|
+
packs and QC) · [all our open source](https://dawnwood.ai/open-source/).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
demusic/__init__.py,sha256=okyxv3OOIcmzz7f8YyUQqTlqudFaMcpjokQ73XHU6Fg,378
|
|
2
|
+
demusic/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
3
|
+
demusic/cli.py,sha256=7Jdj_ueYihjaGPEqMo5BCzaOPlmt5lQiWb46JtRx4cE,4844
|
|
4
|
+
demusic/core.py,sha256=anm3lQZDOAcARYVKrgdZAEFSDYBxcxIK76h-__qPzzk,5794
|
|
5
|
+
demusic/detect.py,sha256=Y1Qh2XyiFtEugY_G-99WqQvJ-2gt-4R1jVeBGmCzmAc,7019
|
|
6
|
+
demusic/ff.py,sha256=e51Fp2Pgsyayoq4Yoj3N6Syt3w1UrGt2onEL7f8krno,3399
|
|
7
|
+
demusic/mcp_server.py,sha256=ZZiD0-jBSvtCFwUwK-dEId_Vvm7TPAYpaCEpku9-SnE,3314
|
|
8
|
+
demusic/provenance.py,sha256=yYowI6xhQM2Z0hvvIppxmnxyyYlqdxamQB4H3Zh8R20,585
|
|
9
|
+
demusic/separate.py,sha256=nhrAAQNUTQ0lhDSYhq22_lvT86HhNMvIig1ZM2UPmmI,3683
|
|
10
|
+
demusic-0.1.0.dist-info/METADATA,sha256=riu7IzizGSLkvpgeBVU1LgCAuQ7QZPbvod70jgzojKk,7395
|
|
11
|
+
demusic-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
12
|
+
demusic-0.1.0.dist-info/entry_points.txt,sha256=v_iL1QYrzxJw-HXQlfva6AQDlg1He8Dabml4CK3Xd00,45
|
|
13
|
+
demusic-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
14
|
+
demusic-0.1.0.dist-info/licenses/NOTICE,sha256=h5W_Jzo-wWjFeXmKGJWV2zkidE49qW6UGYIEOMSyJSw,553
|
|
15
|
+
demusic-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
demusic
|
|
2
|
+
Copyright 2026 Dawnwood, Inc. (https://dawnwood.ai)
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Dawnwood, Inc.
|
|
5
|
+
https://github.com/dawnwood-ai/demusic
|
|
6
|
+
|
|
7
|
+
The music classifier it downloads is MIT's Audio Spectrogram Transformer fine-tuned on
|
|
8
|
+
AudioSet (BSD-3-Clause), ONNX export by onnx-community on Hugging Face.
|
|
9
|
+
|
|
10
|
+
Please keep the "cleaned with demusic by Dawnwood" comment tag that demusic writes into
|
|
11
|
+
output files, and credit "demusic by Dawnwood" when you describe a production pipeline
|
|
12
|
+
that uses it. This is a request, not a license condition.
|