1

I realize that this is a very, very basic question but I started learning Python yesterday so I can make a program I've had the idea for and I'm unable to find any information that would help me in over two hours of Google searches and forum seeking.

For the program that I'm making, I need some of Pydub's functionality, and I can't for the life of me figure out how to import files into my code.

I have Pydub and Pyaudio installed, and "song.mp3" is in the same folder as my project. I made a small script to figure out Pydub's capabilities while isolated from the rest of the project, which looks like this:

from pydub import AudioSegment
from pydub.playback import play

music = AudioSegment.from_mp3("song.mp3")
play(music)

It gives me the error: FileNotFoundError: [WinError 2] The system cannot find the file specified

I appreciate any help, I know this is a really elementary question but I don't know where else to go with it.

Edit: I tried the same thing with a .wav file, because Pydub natively supports them, and I heard a weird, glitchy scratching sound for a second from my speakers before my Youtube tab in Chrome stopped the video player and said "Audio rendering error, please restart your computer."

I closed the program and refreshed the page and everything is fine again, but seriously- wtf?

LumaCurve
  • 11
  • 3
  • Try including the full path to the song. For example, instead of `"song.mp3"`, an absolute path would be `r"C:\Users\John\Desktop\song.mp3"`. Don't forget to include the `r` before the quotation mark since that signifies its a raw string literals and tells python not to use the `\` to escape characters. – Axiumin_ Aug 08 '20 at 22:55
  • Sadly, it gave me the same error – LumaCurve Aug 08 '20 at 23:04
  • you can find your answer here: https://stackoverflow.com/questions/22284461/pydub-windowserror-error-2-the-system-can-not-find-the-file-specified – Peyman Majidi Aug 09 '20 at 06:36
  • Does this answer your question? [Pydub (WindowsError: \[Error 2\] The system can not find the file specified)](https://stackoverflow.com/questions/22284461/pydub-windowserror-error-2-the-system-can-not-find-the-file-specified) – Peyman Majidi Aug 09 '20 at 06:36

1 Answers1

0

Alright ya'll, you were right.

It was indeed an issue with ffmpeg- I didn't have it in my system environment variables

For people in the future coming across this thread, here's a video telling you how to properly install ffmpeg so you can make sure that's not your issue

https://www.youtube.com/watch?v=a_KqycyErd8

Make sure you restart your coding application before testing, because I had to restart Atom for the changes to show up. Thanks to everyone for the help!

LumaCurve
  • 11
  • 3