Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'AudioClip' object has no attribute 'preview' #2289

Open
DarkRedman opened this issue Dec 16, 2024 · 1 comment
Open

AttributeError: 'AudioClip' object has no attribute 'preview' #2289

DarkRedman opened this issue Dec 16, 2024 · 1 comment
Labels
bug Issues that report (apparent) bugs.

Comments

@DarkRedman
Copy link

Expected Behavior

I expect to hear the audio on preview

Actual Behavior

I get this error AttributeError: 'AudioClip' object has no attribute 'preview'

Steps to Reproduce the Problem

I use the code straight from the documentation moviepy.audio.AudioClip.AudioClip

# Plays the note A in mono (a sine wave of frequency 440 Hz)
import numpy as np
frame_function = lambda t: np.sin(440 * 2 * np.pi * t)
clip = AudioClip(frame_function, duration=5, fps=44100)
clip.preview()

# Plays the note A in stereo (two sine waves of frequencies 440 and 880 Hz)
frame_function = lambda t: np.array([
    np.sin(440 * 2 * np.pi * t),
    np.sin(880 * 2 * np.pi * t)
]).T.copy(order="C")
clip = AudioClip(frame_function, duration=3, fps=44100)
clip.preview()

Specifications

  • Python Version: 3.12.7
  • MoviePy Version: 2.1.1
  • Platform Name: Linux
  • Platform Version: 6.6.63-1-MANJARO

Additional Notes

I also tried the audiopreview() method on the AudioClip and I get this traceback

Traceback (most recent call last):
  File "main.py", line 82, in <module>
    test_audio()
  File "main.py", line 68, in test_audio
    clip.audiopreview()
  File "<decorator-gen-47>", line 2, in audiopreview
  File "/usr/lib/python3.12/site-packages/moviepy/decorators.py", line 53, in requires_duration
    return func(clip, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/moviepy/audio/AudioClip.py", line 301, in audiopreview
    ffplay_audiopreview(
  File "<decorator-gen-11>", line 2, in ffplay_audiopreview
  File "/usr/lib/python3.12/site-packages/moviepy/decorators.py", line 53, in requires_duration
    return func(clip, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/moviepy/audio/io/ffplay_audiopreviewer.py", line 154, in ffplay_audiopreview
    previewer.write_frames(chunk)
  File "/usr/lib/python3.12/site-packages/moviepy/audio/io/ffplay_audiopreviewer.py", line 68, in write_frames
    self.logfile.seek(0)
    ^^^^^^^^^^^^
AttributeError: 'FFPLAY_AudioPreviewer' object has no attribute 'logfile'
@DarkRedman DarkRedman added the bug Issues that report (apparent) bugs. label Dec 16, 2024
@OsaAjani
Copy link
Collaborator

Just tried and audiopreview seems to work with latest version (2.1.2), can you confirm (also I just lost hearing in my left ear and my dog is howling in the corner of the room...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

2 participants