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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not support pathlib #273

Closed
secsilm opened this issue May 2, 2018 · 1 comment
Closed

Not support pathlib #273

secsilm opened this issue May 2, 2018 · 1 comment

Comments

@secsilm
Copy link

secsilm commented May 2, 2018

I found that pydub doesn't support pathlib. Hope support it. 馃槃

Steps to reproduce

from pydub import AudioSegment
from pathlib import Path

song_path = Path('never_gonna_give_you_up.mp3')
song = AudioSegment.from_mp3(song_path )

Actual behavior

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-199f26cc20dd> in <module>()
----> 1 song = AudioSegment.from_mp3(song_path)

c:\users\secsi\.virtualenvs\anayzing-jay-chou-songs-eu7t5y6x\lib\site-packages\pydub\audio_segment.py in from_mp3(cls, file, parameters)
    530     @classmethod
    531     def from_mp3(cls, file, parameters=None):
--> 532         return cls.from_file(file, 'mp3', parameters)
    533 
    534     @classmethod

c:\users\secsi\.virtualenvs\anayzing-jay-chou-songs-eu7t5y6x\lib\site-packages\pydub\audio_segment.py in from_file(cls, file, format, codec, parameters, **kwargs)
    469         input_file = NamedTemporaryFile(mode='wb', delete=False)
    470         try:
--> 471             input_file.write(file.read())
    472         except(OSError):
    473             input_file.flush()

AttributeError: 'WindowsPath' object has no attribute 'read'

Your System configuration

  • Python version: Python 3.6.4 :: Anaconda, Inc.
  • Pydub version: 0.21.0
  • ffmpeg or avlib?: ffmpeg
  • ffmpeg/avlib version: N-87043-gf0f4888
@jaden-young
Copy link
Contributor

Hey! I actually fixed this in #252, which made its way into the 0.22.0 release. Bumping the pydub version in your requirements.txt or Pipfile from 0.21.0 to 0.22.0 or higher should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants