refactor update function for windowed view
Browse files
app.py
CHANGED
@@ -26,11 +26,11 @@ def extract_waveform_animation(audio_file):
|
|
26 |
def update(frame):
|
27 |
start = frame * sr
|
28 |
end = min(start + sr, len(y))
|
29 |
-
line.set_data(np.linspace(
|
30 |
return line,
|
31 |
|
32 |
# Create the animation
|
33 |
-
ani = FuncAnimation(fig, update,
|
34 |
|
35 |
# Save the animation to a temporary file
|
36 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tmpfile:
|
|
|
26 |
def update(frame):
|
27 |
start = frame * sr
|
28 |
end = min(start + sr, len(y))
|
29 |
+
line.set_data(np.linspace(start, end, num=len(y[:end])), y[:end])
|
30 |
return line,
|
31 |
|
32 |
# Create the animation
|
33 |
+
ani = FuncAnimation(fig, update, init_func=init, interval=7, blit=False)
|
34 |
|
35 |
# Save the animation to a temporary file
|
36 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tmpfile:
|