Spaces:
Sleeping
Sleeping
Update generalstems.py
Browse files- generalstems.py +0 -15
generalstems.py
CHANGED
|
@@ -164,22 +164,7 @@ def detect_tempo_advanced(y, sr):
|
|
| 164 |
bpm = round(bpm)
|
| 165 |
|
| 166 |
return int(bpm)
|
| 167 |
-
|
| 168 |
-
except ImportError:
|
| 169 |
-
pass
|
| 170 |
-
|
| 171 |
-
# Librosa fallback - simple and accurate
|
| 172 |
-
y_percussive = librosa.effects.percussive(y, margin=3)
|
| 173 |
-
onset_env = librosa.onset.onset_strength(y=y_percussive, sr=sr)
|
| 174 |
-
tempo_result = librosa.beat.tempo(onset_envelope=onset_env, sr=sr, aggregate=np.median)
|
| 175 |
-
|
| 176 |
-
if isinstance(tempo_result, np.ndarray):
|
| 177 |
-
tempo = float(tempo_result[0]) if len(tempo_result) > 0 else 120.0
|
| 178 |
-
else:
|
| 179 |
-
tempo = float(tempo_result)
|
| 180 |
|
| 181 |
-
return int(round(tempo))
|
| 182 |
-
|
| 183 |
# -----------------------------
|
| 184 |
# Convert MP3 → WAV
|
| 185 |
# -----------------------------
|
|
|
|
| 164 |
bpm = round(bpm)
|
| 165 |
|
| 166 |
return int(bpm)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
|
|
|
|
|
|
| 168 |
# -----------------------------
|
| 169 |
# Convert MP3 → WAV
|
| 170 |
# -----------------------------
|