1

I've tried to reduce or raise the volume of an audio clip using pydub. But when I did so it is giving following error.

 c:/Users/KalyanDk/vsprojects/Games/playsound.py
C:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py:165: 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:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py:179: 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/KalyanDk/vsprojects/Games/playsound.py", line 12, in <module>
    play(louder_song)
  File "C:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\playback.py", line 71, in play
    _play_with_ffplay(audio_segment)
  File "C:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\playback.py", line 18, in _play_with_ffplay
    seg.export(f.name, "wav")
  File "C:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\audio_segment.py", line 780, in export
    out_f = _fd_or_path_or_tempfile(out_f, 'wb+')
  File "C:\Users\KalyanDk\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py", line 57, in _fd_or_path_or_tempfile
    fd = open(fd, mode=mode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\KalyanDk\\AppData\\Local\\Temp\\tmposf_nhdb.wav'

I'm not able to understand what is wrong..Here is my code

from pydub import AudioSegment
from pydub.playback import play

song = AudioSegment.from_wav("Bounce.wav")

louder_song = song + 6

quieter_song = song - 3

play(louder_song)

louder_song.export("Bounce.wav", format='wav')'''

And the audio file is in the same folder where the current python file reside.

Tupteq
  • 2,986
  • 1
  • 21
  • 30
kalyan dk
  • 19
  • 4

1 Answers1

0

Try installing simpleaudio: pip install simpleaudio

Pydub uses NamedTemporaryFile many times throughout the program, including in the play() method. There are some apparent inconsistencies across platforms in the way NamedTemporaryFile handles basic file operations. I believe simpleaudio will circumvent the code where NamedTemporaryFile is called in the play() method, though I'm not clear on if this solves the issue for all instances of NamedTemporaryFile in pydub. Simpleaudio definitely fixed the issue for me though - no config needed, just install.

ref: https://github.com/jiaaro/pydub/issues/343

befunkt
  • 131
  • 8