Open RickyWang111 opened 2 years ago
Hello, had the same issue. Use / instead of \ in the filepath Like that:
from pydub.playback import play
from pydub import AudioSegment
a=AudioSegment.from_wav(r'G:/aaaa11.wav')
play(a)
The issue isn't opening the source sound file. The issue is with pydub.playback.play() writing a file in the user's TEMP directory as shown in the last line of the @RickyWang111 output. Perhaps somewhere in the utils.py code there is some code that Windows is choking on. Someone suggested installing simpleaudio to replace the tempfile code but that didn't work for me.
I'm having the same problem on Windows 10 with Python 3.11.1 (released today)
I note that I have no trouble writing temporary files using the tempfile package.
I got the same problem and by luck I tested to set "delete=False" in the below code:
This was after I installed ffmpeg and added it to path... Now it plays the sound in my sample wav-file. However, now it will fill up with a new wav file in temp directory each time I play the sound I guess... This problem is beyond my paygrade :-)
The errant code is likely in the utils.py where the code tries to figure out how near the temporary file is to being open. The problem is shown as being in the function def _fd_or_path_or_tempfile where it tries to determine at what stage the opening of the temporary file is: None, a string (the file path) or a file handle.
Ideally, the Tempfile wouldn't need to be checked and rechecked and I suspect the problem lies in trying to open a file that is already opened by either the TemporaryFile or NamedTemporaryFile functions of the tempfile package.
I got the same problem and by luck I tested to set "delete=False" in the below code:
thanks, it works for me
mian3kth 님 감사합니다.
I got the same problem and by luck I tested to set "delete=False" in the below code:
It does indeed work but EVERY time you play an audio, it generates a temporary file which does NOT get deleted since you have provided that argument causing the memory to be filled with temporary files if you ever integrate this in an actual software.
(Translate) Mesmo fazendo isso aí, agora to recebendo esse erro:
Failed to set value 'C:\Users\WINDOW~1\AppData\Local\Temp\tmp2kxg6ejz.wav' for option 'hide_banner': Option not found
For windows, installing PyAudio solved the issue of permissions.
i have to say that after i solved by "delete=False", ffplay still doesn't have sound in windows. so i used the pyaudio to play sound.
Steps to reproduce
Expected behavior
Audio should be played normally.
Actual behavior
Outputs of section "Steps to reporduce" mentioned:
Your System configuration