pydub icon indicating copy to clipboard operation
pydub copied to clipboard

Conversion mp3 to wav not possible?

Open Rapid1898-code opened this issue 1 year ago • 1 comments

Hello - i try to convert a mp3-file to a wav-file with the following code:

import os
import sys
from pydub import AudioSegment

if __name__ == '__main__':
  path = os.path.abspath(os.path.dirname(sys.argv[0])) 
  fn = os.path.join(path, "work.mp3")
  sound = AudioSegment.from_mp3(fn)
  sound.export("transcript.wav", format="wav")

But i allways get this error:

$ python try.py
G:\DEV\Fiverr\TRY\saraboargs\work.mp3
G:\DEV\.venv\selAll\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "G:\DEV\Fiverr\TRY\saraboargs\try.py", line 18, in <module>
    sound = AudioSegment.from_mp3(fn)
  File "G:\DEV\.venv\selAll\lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)
  File "G:\DEV\.venv\selAll\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "G:\DEV\.venv\selAll\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\marku\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\marku\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

ffmpeg seems to be installed on the computer

$ ffmpeg --version
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Unrecognized option '-version'.
Error splitting the argument list: Option not found

Why is the conversion not working with this code?

Rapid1898-code avatar Feb 26 '23 10:02 Rapid1898-code

Hi, So I think your ffmpeg might not be linked to your conda env (in case you are using one) I had the same issue but after downloading ffmpeg and manually moving it to /Users/mac/opt/anaconda3/bin/ffmpeg it worked

5hv5hvnk avatar Apr 08 '23 10:04 5hv5hvnk