1

I am trying to split mp3 file into chunks by silence and getting

  File "C:\Anaconda3\envs\py27\lib\site-packages\pydub\playback.py", line 71, in play
    _play_with_ffplay(audio_segment)
  File "C:\Anaconda3\envs\py27\lib\site-packages\pydub\playback.py", line 18, in _play_with_ffplay
    seg.export(f.name, "wav")
  File "C:\Anaconda3\envs\py27\lib\site-packages\pydub\audio_segment.py", line 780, in export
    out_f = _fd_or_path_or_tempfile(out_f, 'wb+')
  File "C:\Anaconda3\envs\py27\lib\site-packages\pydub\utils.py", line 57, in _fd_or_path_or_tempfile
    fd = open(fd, mode=mode)
IOError: [Errno 13] Permission denied: 'd:\\tmp\\tmpo5dfj5.wav'

while I am trying to play it

        audio = AudioSegment.from_mp3(lessonFilePath)
        chunks = split_on_silence(audio, min_silence_len=2000, silence_thresh=-16)
        ordinalAudio = 0
        chunk = chunks[ordinalAudio]
        play(chunk) # here it is rising

I have access to this directory and I can execute

fd = open(fd, mode=mode)

in my own separate script.

What else can be checked?

Dims
  • 47,675
  • 117
  • 331
  • 600

1 Answers1

4

The issue has to do with how pydub manages temporary audio files. Pydub currently has a bug where it will open a temporary file multiple times, which works on linux but will result in the observed bug on windows (and possibly mac os, I haven't checked). One remedy is to pip install simpleaudio which will take over as the default temp file management system for pydub once installed.

theo
  • 61
  • 1
  • 3