Upload 3 files
Browse files- app.py +2 -5
- packages.txt +2 -2
- requirements.txt +4 -4
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
import librosa
|
| 3 |
import base64
|
| 4 |
import os
|
|
@@ -25,7 +25,6 @@ if uploaded_file is not None:
|
|
| 25 |
y, sr = librosa.load(audio_path)
|
| 26 |
_, y_percussive = librosa.effects.hpss(y)
|
| 27 |
tempo, drum_frames = librosa.beat.beat_track(y=y_percussive, sr=sr)
|
| 28 |
-
# 强制转换类型,防止 JavaScript 崩溃
|
| 29 |
drum_times = [round(float(t), 3) for t in librosa.frames_to_time(drum_frames, sr=sr)]
|
| 30 |
onset_env_bass = librosa.onset.onset_strength(y=y, sr=sr, fmax=250, n_mels=16)
|
| 31 |
bass_frames = librosa.onset.onset_detect(onset_envelope=onset_env_bass, sr=sr)
|
|
@@ -58,8 +57,6 @@ if uploaded_file is not None:
|
|
| 58 |
video {{ width: 100%; border-radius: 8px; }}
|
| 59 |
#waveform {{ width: 100vw; margin-left: -5px; background: #1e1e1e; padding: 10px 0; overflow-x: hidden; }}
|
| 60 |
.btn {{ background: #ff5722; color: white; border: none; padding: 15px 0; width: 100%; font-size: 18px; font-weight: bold; border-radius: 8px; cursor: pointer; margin-top: 10px; }}
|
| 61 |
-
.region-beat {{ color: rgba(255,255,255,0.7); font-size: 12px; padding: 2px; }}
|
| 62 |
-
.region-one {{ color: #ffffff; font-size: 16px; font-weight: bold; padding: 2px 6px; background: rgba(255,87,34,0.9); border-radius: 4px; }}
|
| 63 |
</style>
|
| 64 |
</head>
|
| 65 |
<body>
|
|
@@ -106,4 +103,4 @@ if uploaded_file is not None:
|
|
| 106 |
</body>
|
| 107 |
</html>
|
| 108 |
"""
|
| 109 |
-
st.components.v1.html(html_code, height=750, scrolling=True)
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import librosa
|
| 3 |
import base64
|
| 4 |
import os
|
|
|
|
| 25 |
y, sr = librosa.load(audio_path)
|
| 26 |
_, y_percussive = librosa.effects.hpss(y)
|
| 27 |
tempo, drum_frames = librosa.beat.beat_track(y=y_percussive, sr=sr)
|
|
|
|
| 28 |
drum_times = [round(float(t), 3) for t in librosa.frames_to_time(drum_frames, sr=sr)]
|
| 29 |
onset_env_bass = librosa.onset.onset_strength(y=y, sr=sr, fmax=250, n_mels=16)
|
| 30 |
bass_frames = librosa.onset.onset_detect(onset_envelope=onset_env_bass, sr=sr)
|
|
|
|
| 57 |
video {{ width: 100%; border-radius: 8px; }}
|
| 58 |
#waveform {{ width: 100vw; margin-left: -5px; background: #1e1e1e; padding: 10px 0; overflow-x: hidden; }}
|
| 59 |
.btn {{ background: #ff5722; color: white; border: none; padding: 15px 0; width: 100%; font-size: 18px; font-weight: bold; border-radius: 8px; cursor: pointer; margin-top: 10px; }}
|
|
|
|
|
|
|
| 60 |
</style>
|
| 61 |
</head>
|
| 62 |
<body>
|
|
|
|
| 103 |
</body>
|
| 104 |
</html>
|
| 105 |
"""
|
| 106 |
+
st.components.v1.html(html_code, height=750, scrolling=True)
|
packages.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
libsndfile1
|
|
|
|
| 1 |
+
ffmpeg
|
| 2 |
+
libsndfile1
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
librosa
|
| 3 |
-
moviepy==1.0.3
|
| 4 |
-
numpy
|
|
|
|
| 1 |
+
streamlit==1.30.0
|
| 2 |
+
librosa
|
| 3 |
+
moviepy==1.0.3
|
| 4 |
+
numpy
|