perf: slim daw_engine bundle 409MB->170MB + fix engine khong chay tren Windows
- Thay librosa bang app/core/audio_features.py (numpy/scipy/soundfile):
load, beat_track, frames_to_time, spectral_centroid, rms, zero_crossing_rate,
time_stretch, pitch_shift, chroma_stft. A/B ngang librosa (BPM <1% sai lech,
pitch_shift chuan toi Hz). Loai bo llvmlite 171MB + scikit-learn + numba.
- Task layer 2 che do (app/tasks/worker.py): server giu celery; desktop slim
chay in-process thread + registry, giu nguyen API contract (.delay/.id/status
/tasks/{id}) nen frontend khong doi.
- engine.spec: excludes librosa/numba/llvmlite/sklearn/celery/redis/kombu/
billiard/amqp/msgpack/yaml/PIL/cairosvg/zstandard/...; scan scipy gioi han
scipy.signal; giu click (uvicorn.main import click).
- render_engine: scipy.signal thanh lazy import (giam cold start).
- tauri.conf.json: targets [nsis, msi] - NSIS tro lai (bundle nho) de
hooks.nsh cai VC++ Redistributable - sua bug daw_engine.exe khong chay
tren Windows (truoc day MSI-only khong chay hooks).
- build_linux.sh / build_macos.sh: build 1 lenh moi OS.
- Doc: DESKTOP_INSTALL_PLAN.md muc 5.1.
- Verify: 86 tests pass, engine dong goi upload/analyze/waveform/export OK.
This commit is contained in:
@@ -75,13 +75,16 @@ class AIDSPEngine:
|
||||
t_end = min(total_duration, 4.0)
|
||||
|
||||
try:
|
||||
import librosa
|
||||
# 1. Compute harmonic structural properties via Chroma Constant-Q Transform
|
||||
chroma = librosa.feature.chroma_cqt(y=y_mono, sr=sr)
|
||||
from app.core.audio_features import chroma_stft as _chroma_stft
|
||||
# 1. Compute harmonic structural properties via Chroma (STFT-based,
|
||||
# thay chroma_cqt de lo bo librosa/numba/llvmlite ~171MB)
|
||||
chroma = _chroma_stft(y=y_mono, sr=sr)
|
||||
|
||||
# 2. Compile Self-Similarity Matrix (Cosine Recurrence Plot)
|
||||
from sklearn.metrics.pairwise import cosine_similarity
|
||||
ssm = cosine_similarity(chroma.T, chroma.T)
|
||||
# thay sklearn.metrics.pairwise.cosine_similarity bang numpy
|
||||
c = chroma.T # (n_frames, 12)
|
||||
norms = np.linalg.norm(c, axis=1, keepdims=True)
|
||||
ssm = (c @ c.T) / (norms @ norms.T + 1e-9)
|
||||
|
||||
num_frames = ssm.shape[0]
|
||||
hop_length = 512
|
||||
|
||||
Reference in New Issue
Block a user