Open vincenzoml opened 11 months ago
I found out the issue comes from recent numpy (> 1.25.1) which probably enforces deprecation of some behaviour. Using numpy 1.24.4 is a way to overcome the issue temporarily, but I guess moviepy should be updated.
I encountered the same bug. Is there a resolution for this issue?
Details:
NumPy Version: 1.24.3 (No error) NumPy Version: 1.26.0
TypeError
arrays to stack must be passed as a "sequence" type such as list or tuple.
File "/app/exec.py", line 54, in <module>
audio = video_clip.audio.to_soundarray()
TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.
Encountered the same issue.
For those who are stuck a workaround to using to_soundarray()
can be something like this:
# Load the clip
audio_clip = mpy.AudioFileClip(filename)
# Extract the audio as a list of samples
audio_samples = list(audio_clip.iter_frames())
# Convert the list of samples to a NumPy array
sound_array = np.array(audio_samples)
It seems that this issue was raised and fixed before but then the fix was deleted from the codebase for some reason...
It seems that this issue was raised and fixed before but then the fix was deleted from the codebase for some reason...
@Geometrein what do you mean by "but then the fix was deleted from the codebase"? The fix you refer to is in master
, isn't it?
As pointed out by @keikoro, the fix is present in master, but not in the commit db19920 used for the latest release on PyPi (1.0.3 as of today): https://github.com/Zulko/moviepy/blob/db19920764b5cb1d8aa6863019544fd8ae0d3cce/moviepy/audio/AudioClip.py#L113-L114
It looks like the 1.0.3 version is already 4 years old!
In the meantime, you can install the package directly from the git repo like so:
pip install git+https://github.com/Zulko/moviepy.git
I have a function to load audio to an array that looks more or less like this:
Expected Behavior
The audio is converted to an array
Actual Behavior
I get the following error on "clip.to_soundarray"
Specifications