cleanup: remove dead code and duplicate docs
- Remove session-ses_2f27.md (161KB raw session log) - Remove 49 ROOT_* duplicate files across REFERENCE/ - Remove 14 duplicate files between REFERENCE/ root and history/ - Remove asr_legacy.rs (dead code, replaced by asr.rs) - Remove src/core/worker/ (duplicate JobWorker) - Remove src/core/layers/ (empty directory) - Remove 4 .bak files in src/ - Remove 7 dead private methods in worker/processor.rs - Remove backup directory from git tracking
This commit is contained in:
@@ -8,7 +8,6 @@ import librosa
|
||||
import numpy as np
|
||||
import os
|
||||
import json
|
||||
import matplotlib.pyplot as plt # Only for debug if needed, but we stick to console for now
|
||||
|
||||
# 設定
|
||||
UUID = os.getenv("UUID", "384b0ff44aaaa1f1")
|
||||
@@ -29,7 +28,7 @@ def analyze_music_segmentation(audio_path):
|
||||
hop_length = int(1.0 * sr)
|
||||
chroma = librosa.feature.chroma_stft(y=y, sr=sr, hop_length=hop_length)
|
||||
|
||||
print(f"📊 Analyzing transitions...")
|
||||
print("📊 Analyzing transitions...")
|
||||
|
||||
# 2. 計算自我相似度矩陣 (Self-Similarity Matrix) - 優化版
|
||||
# 這裡我們簡化為計算相鄰片段的餘弦距離 (Cosine Distance)
|
||||
@@ -45,7 +44,6 @@ def analyze_music_segmentation(audio_path):
|
||||
|
||||
# 使用 librosa 的 onset_strength 的變體,但針對 Chroma
|
||||
# 這裡手動計算 Cosine Distance 以確保準確度
|
||||
from sklearn.metrics.pairwise import cosine_similarity
|
||||
|
||||
# 為了效能,我們不逐一計算,而是使用向量化的方法
|
||||
# 計算 frame[t] 和 frame[t+lag] 的差異
|
||||
@@ -127,12 +125,12 @@ if __name__ == "__main__":
|
||||
with open(OUTPUT_JSON, "w", encoding="utf-8") as f:
|
||||
json.dump({"music_segments": segments}, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print(f"\n🎉 Analysis Complete!")
|
||||
print("\n🎉 Analysis Complete!")
|
||||
print(f"✅ Identified {len(segments)} music-based scenes.")
|
||||
print(f"💾 Saved to {OUTPUT_JSON}")
|
||||
|
||||
# 顯示結果
|
||||
print(f"\n🎶 Top Music Segments:")
|
||||
print("\n🎶 Top Music Segments:")
|
||||
for i, seg in enumerate(segments[:20]):
|
||||
m_s, s_s = divmod(seg["start_time"], 60)
|
||||
print(f" {i + 1:02d}. [{int(m_s):02d}:{s_s:05.2f}] - {seg['duration']}s")
|
||||
|
||||
Reference in New Issue
Block a user