0

I have pip installed python-ffmpeg and am trying to play a wav file with PyDub. I get this warning:

   Warning (from warnings module):
  File "C:\Users\divel\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\utils.py", line 170
    warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work

And then a permission error:

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\divel\\AppData\\Local\\Temp\\tmp0t700dh0.wav'

Any suggestions on how to fix it? The code itself is:

from pydub import AudioSegment
from pydub.playback import play

snippet = AudioSegment.from_file('suoni\snippet6.wav', format = 'wav')
play(snippet)
FulvioD 23
  • 17
  • 5
  • Refer to this question on how to specify the ffmpeg path: https://stackoverflow.com/questions/22284461/pydub-windowserror-error-2-the-system-can-not-find-the-file-specified/24354699#24354699 About the permission problem: you have to run your Python program as user `divel` or as administrator in order to have to permissions to modify this temporary folder. – davidpace Aug 13 '22 at 11:29
  • Thank you. I have installed ffmpeg in C and set the path to it. I have tried both ```AudioSegment.ffmpeg = "/C/ffmpeg"``` and ```AudioSegment.converter = "/C/ffmpeg''``` but to no avail: the same error persits. I am running this in IDLE but I don't understand how can I run it as administrator. Thank you very much for your help. – FulvioD 23 Aug 19 '22 at 11:12
  • 1
    Try this answer [HERE](https://stackoverflow.com/a/73601217/19808651) It solves the permission error. – KyngZey Sep 04 '22 at 18:28

1 Answers1

0

I'm assuming your operating system is Windows. In this case you should specify the location where you installed ffmpeg using the class attribute AudioSegment.converter and one of the following path syntax variants:

AudioSegment.converter = 'C:/ffmpeg'
AudioSegment.converter = 'C:\\ffmpeg'

Note the double backslash in the second path, as backslashes are used as escape characters, so backslashes have to be escaped with a backslash ;)

You could try right-clicking the IDLE link or the IDLE executable (.exe) and then choosing Run as Administrator to solve the permission issue.

davidpace
  • 405
  • 4
  • 7
  • Sorry for not having specified this beforehand, I am indeed operating on Windows. I have tried both solutions and they don't work. It's quite frustrating because I tried to use PyDub on LinuxMint and it works like a charm... – FulvioD 23 Aug 23 '22 at 13:01
  • Hmm...have you actually installed ffmpeg at `C:\ffmpeg` or maybe another location like `C:\Program Files (x86)\ffmpeg`? Also check the exact spelling regarding upper and lowercase letters. In fact it's best to copy the exact path from the Windows Explorer. Please also try the `bin` folder or even the complete path to ffmpeg.exe, e.g. `C:\ffmpeg\bin` and `C:\ffmpeg\bin\ffmpeg.exe`. – davidpace Aug 23 '22 at 19:54
  • I tried it all, also while running Python as administrator: still stuck with Errno 13. Thank youvery much for your help, this is becoming unnerving. – FulvioD 23 Aug 25 '22 at 12:43
  • I noticed that you use a path with a single slash in the `AudioSegment.from_file()` call. Try replacing `suoni\snippet6.wav` with `suoni\\snippet6.wav` or `suoni/snippet6.wav`. Alternatively you could try using an absolute path like `C:\\Users\\whatever\\path\\snippet6.wav`. Does that help? – davidpace Aug 27 '22 at 08:43
  • Thank you again. I tried all the possible different combinations but it still isn't working. – FulvioD 23 Aug 31 '22 at 10:20