music-lens 0.1.0 → 0.1.2
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.
- package/README.md +24 -2
- package/bin/music-lens.mjs +39 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
不需要人耳,也不需要联网(模型已下到本地)。给纯文本的模型用:把声音变成它能读的数字和图。
|
|
6
6
|
|
|
7
|
+
> **第一次用?看 [`docs/新手操作指南.md`](docs/新手操作指南.md)** —— 面向完全没写过代码的人,
|
|
8
|
+
> 三步装好,七个坑都写在里面。
|
|
9
|
+
> 要做视频/图文分享的话,[`docs/发布文案.md`](docs/发布文案.md) 里有标题、简介和口播稿。
|
|
10
|
+
|
|
7
11
|
```bash
|
|
8
12
|
npm i -g music-lens # 或者 git clone 后 npm i -g .
|
|
9
13
|
music-lens setup # 装 python 依赖 + 下模型(约 2 GB)
|
|
@@ -23,12 +27,16 @@ $node = "C:\Users\86173\Documents\deepseek-harness\default-workspace\snowluma\Sn
|
|
|
23
27
|
& $node .\bin\music-lens.mjs analyze "song.mp3" --model medium
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
`setup` 会自己装 python 依赖并从 hf-mirror
|
|
30
|
+
`setup` 会自己装 python 依赖并从 hf-mirror 下模型,**默认只下 small(461 MB)**:
|
|
27
31
|
|
|
28
32
|
```powershell
|
|
29
|
-
& $node .\bin\music-lens.mjs setup
|
|
33
|
+
& $node .\bin\music-lens.mjs setup # small,约 500 MB 依赖 + 461 MB 模型
|
|
34
|
+
& $node .\bin\music-lens.mjs setup --models medium # 中文效果更好,再下 1.46 GB
|
|
30
35
|
```
|
|
31
36
|
|
|
37
|
+
跨平台:Windows 用 `winget`,macOS 用 `brew`,Linux 用 `apt-get`;
|
|
38
|
+
都不行时会打印手工安装命令,也可以用 `MUSIC_LENS_PYTHON` 直接指定解释器路径。
|
|
39
|
+
|
|
32
40
|
模型和缓存默认放 `~/.music-lens`,可用 `MUSIC_LENS_HOME` 覆盖。
|
|
33
41
|
|
|
34
42
|
> 本机注意:**node 不在 PATH 里,也没有 npm**,所以 `npx music-lens` 目前跑不了,
|
|
@@ -129,3 +137,17 @@ $base = "C:\Users\86173\Documents\deepseek-harness\default-workspace\music-lens"
|
|
|
129
137
|
- [ ] 用 `librosa.pyin` 出逐帧基频,画"音高随时间的走向"
|
|
130
138
|
- [ ] 情绪的 arousal 维度(能量+亮度已经能算个大概)
|
|
131
139
|
- [ ] 换 `large-v3`(3 GB,CPU 上慢约 4 倍,中文应该更准)
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 致谢
|
|
144
|
+
|
|
145
|
+
这个包的代码、文档、测试,以及下面那七条踩坑记录,全部由 **DSH(DeepSeek Harness)里的 AI 助手**
|
|
146
|
+
在 2026-11-01 的一次会话中完成(模型 `deepseek-flash`)。
|
|
147
|
+
|
|
148
|
+
它不能拥有账号、不能发布 npm 包、也不能处理 issue——所以仓库和包的所有权、维护责任在人类这边。
|
|
149
|
+
这份致谢记录的是“谁写的”,不是转移责任。
|
|
150
|
+
|
|
151
|
+
过程中被人类纠正过两次重要判断:先说“情绪和歌词做不出来”(错的,歌词能做),
|
|
152
|
+
又说“节点不在 PATH 就装不了”(也是错的)。所以文档里那些边界条件,有一半是吵出来的。
|
|
153
|
+
|
package/bin/music-lens.mjs
CHANGED
|
@@ -57,13 +57,15 @@ function parseArgs(argv) {
|
|
|
57
57
|
function candidates() {
|
|
58
58
|
const list = []
|
|
59
59
|
if (process.env.MUSIC_LENS_PYTHON) list.push(process.env.MUSIC_LENS_PYTHON)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (process.platform === 'win32') {
|
|
61
|
+
const la = process.env.LOCALAPPDATA
|
|
62
|
+
if (la) {
|
|
63
|
+
for (const v of ['313', '312', '311']) {
|
|
64
|
+
list.push(path.join(la, 'Programs', 'Python', `Python${v}`, 'python.exe'))
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
list.push('
|
|
68
|
+
list.push('python3.12', 'python3', 'python')
|
|
67
69
|
return list
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -135,8 +137,8 @@ function cmdDoctor() {
|
|
|
135
137
|
const py = findPython()
|
|
136
138
|
if (!py) {
|
|
137
139
|
log('python : MISSING')
|
|
138
|
-
log(
|
|
139
|
-
log(' or set MUSIC_LENS_PYTHON
|
|
140
|
+
log(` install: ${pythonInstallCommand().manual}`)
|
|
141
|
+
log(' or set MUSIC_LENS_PYTHON=/path/to/python')
|
|
140
142
|
} else {
|
|
141
143
|
const v = capture(py, ['-c', 'import sys;print(sys.version.split()[0])']).out.trim()
|
|
142
144
|
log(`python : ${py} (${v})`)
|
|
@@ -151,16 +153,38 @@ function cmdDoctor() {
|
|
|
151
153
|
return 0
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
function pythonInstallCommand() {
|
|
157
|
+
if (process.platform === 'win32') {
|
|
158
|
+
return {
|
|
159
|
+
cmd: 'winget',
|
|
160
|
+
args: ['install', '--id', 'Python.Python.3.12', '-e', '--scope', 'user',
|
|
161
|
+
'--accept-package-agreements', '--accept-source-agreements'],
|
|
162
|
+
manual: 'winget install --id Python.Python.3.12 -e --scope user',
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (process.platform === 'darwin') {
|
|
166
|
+
return { cmd: 'brew', args: ['install', 'python@3.12'], manual: 'brew install python@3.12' }
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
cmd: 'sudo',
|
|
170
|
+
args: ['apt-get', 'install', '-y', 'python3', 'python3-pip', 'python3-venv'],
|
|
171
|
+
manual: 'sudo apt-get install -y python3 python3-pip python3-venv',
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
154
175
|
async function cmdSetup(args) {
|
|
155
176
|
const py = findPython()
|
|
156
177
|
let use = py
|
|
157
178
|
if (!use) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
const inst = pythonInstallCommand()
|
|
180
|
+
log(`python not found -- trying ${inst.cmd}`)
|
|
181
|
+
let st = 1
|
|
182
|
+
try { st = run(inst.cmd, inst.args) } catch { st = 1 }
|
|
183
|
+
if (st !== 0) {
|
|
184
|
+
die(`could not install python automatically.\n run manually: ${inst.manual}\n then re-run: music-lens setup\n (or point MUSIC_LENS_PYTHON at an existing python 3.9+)`)
|
|
185
|
+
}
|
|
162
186
|
use = findPython()
|
|
163
|
-
if (!use) die('python installed but still not
|
|
187
|
+
if (!use) die('python installed but still not on PATH; set MUSIC_LENS_PYTHON')
|
|
164
188
|
}
|
|
165
189
|
log(`python: ${use}`)
|
|
166
190
|
|
|
@@ -175,10 +199,11 @@ async function cmdSetup(args) {
|
|
|
175
199
|
'--index-url', 'https://download.pytorch.org/whl/cpu'])
|
|
176
200
|
}
|
|
177
201
|
|
|
178
|
-
const wanted = (args.models || 'small
|
|
202
|
+
const wanted = (args.models || 'small').split(',').map(s => s.trim()).filter(Boolean)
|
|
179
203
|
for (const m of wanted) await ensureModel(m)
|
|
180
204
|
|
|
181
205
|
log('\nready. try: music-lens analyze "<song.mp3>" --model medium')
|
|
206
|
+
log('(medium is ~1.5 GB and a lot better on Chinese; download it with: music-lens setup --models medium)')
|
|
182
207
|
return 0
|
|
183
208
|
}
|
|
184
209
|
|
|
@@ -212,7 +237,7 @@ function usage() {
|
|
|
212
237
|
log(`music-lens ${JSON.parse(fs.readFileSync(path.join(PKG, 'package.json'), 'utf8')).version}
|
|
213
238
|
|
|
214
239
|
music-lens doctor check environment
|
|
215
|
-
music-lens setup [--models small
|
|
240
|
+
music-lens setup [--models small] install python deps + models
|
|
216
241
|
music-lens analyze <audio> transcribe + analyse
|
|
217
242
|
[--model medium] small | medium | large-v3 | path
|
|
218
243
|
[--lang auto] language code or auto
|
package/package.json
CHANGED