I'm trying to use pydub for a music project, but when trying to play sounds with this chunk of code
from pydub import AudioSegment
from pydub.playback import play
sound = AudioSegment.from_wav("s1.wav")
play(sound)
i get the following error:
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Python\Python385\lib\site-packages\pydub\utils.py:184: RuntimeWarning: Couldn't find ffplay or avplay - defaulting to ffplay, but may not work
warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:/Users/vicen/Desktop/music project/mian.py", line 6, in <module>
play(s1)
File "C:\Python\Python385\lib\site-packages\pydub\playback.py", line 74, in play
_play_with_ffplay(audio_segment)
File "C:\Python\Python385\lib\site-packages\pydub\playback.py", line 18, in _play_with_ffplay
seg.export(f.name, "wav")
File "C:\Python\Python385\lib\site-packages\pydub\audio_segment.py", line 809, in export
out_f, _ = _fd_or_path_or_tempfile(out_f, 'wb+')
File "C:\Python\Python385\lib\site-packages\pydub\utils.py", line 60, in _fd_or_path_or_tempfile
fd = open(fd, mode=mode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\vicen\\AppData\\Local\\Temp\\tmpvwotqts5.wav'
Does someone understand why it isn't working? I am fairly new to python so i don't.
The python script encountered a
Permission Error
It is trying to read'C:\\Users\\vicen\\AppData\\Local\\Temp\\tmpvwotqts5.wav'
file but doesn't have permission to write in the directory.Changing permissions on the above mentioned Temp folder should solve the problem.
Or you could run your python script using
sudo
command. Since you are using windows this should help in this regard.