Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python将.mp3转换为.wav?_Python_Mp3_Wav_Pydub - Fatal编程技术网

如何使用python将.mp3转换为.wav?

如何使用python将.mp3转换为.wav?,python,mp3,wav,pydub,Python,Mp3,Wav,Pydub,我尝试使用pydub将mp3转换为wav,但出现以下错误: OSError Traceback (most recent call last) <ipython-input-43-d2334601378c> in <module>() 5 dst= '/Users/user/Downloads/audio_files/5.wav' 6 ----> 7 sound = Aud

我尝试使用pydub将mp3转换为wav,但出现以下错误:

OSError                                   Traceback (most recent call last)
<ipython-input-43-d2334601378c> in <module>()
      5 dst= '/Users/user/Downloads/audio_files/5.wav'
      6 
----> 7 sound = AudioSegment.from_mp3(src)
      8 sound.export(dst, format="wav")

/anaconda2/lib/python2.7/site-packages/pydub/audio_segment.pyc in from_mp3(cls, file, parameters)
    714     @classmethod
    715     def from_mp3(cls, file, parameters=None):
--> 716         return cls.from_file(file, 'mp3', parameters=parameters)
    717 
    718     @classmethod

/anaconda2/lib/python2.7/site-packages/pydub/audio_segment.pyc in from_file(cls, file, format, codec, parameters, **kwargs)
    663             stdin_data = file.read()
    664 
--> 665         info = mediainfo_json(orig_file)
    666         if info:
    667             audio_streams = [x for x in info['streams']

/anaconda2/lib/python2.7/site-packages/pydub/utils.pyc in mediainfo_json(filepath)
    261 
    262     command = [prober, '-of', 'json'] + command_args
--> 263     res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
    264     output, stderr = res.communicate(input=stdin_data)
    265     output = output.decode("utf-8", 'ignore')

/anaconda2/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    392                                 p2cread, p2cwrite,
    393                                 c2pread, c2pwrite,
--> 394                                 errread, errwrite)
    395         except Exception:
    396             # Preserve original exception in case os.close raises.

/anaconda2/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
   1045                         raise
   1046                 child_exception = pickle.loads(data)
-> 1047                 raise child_exception
   1048 
   1049 

OSError: [Errno 2] No such file or directory

使用python3而不是python2.7 python3命令我为它做了什么 convert.py

Pydub安装:


您正在向我们隐藏其余的错误消息。printos.path.isfilesrc的结果是什么?您需要先导入os.printos.path.isfilesrc输出为'True'我猜您看到了一个找不到ffprobe或avprobe-默认为ffprobe,但可能无法工作的警告。您的路径中可能没有ffbrobe或avprobe。如果您这样做,它将由于某些原因无法运行。我尝试在终端中安装pydub此错误发生sudo:add apt repository:command not foundOk使用此命令sudo apt get install software properties common和sudo apt get update我更新了我的帖子
src= '/Users/user/Downloads/audio_files/5.mp3'
dst= '/Users/user/Downloads/audio_files/5.wav'

sound = AudioSegment.from_mp3(src)
sound.export(dst, format="wav")
from pydub import AudioSegment
sound = AudioSegment.from_mp3("test.mp3")
sound.export("test.wav", format="wav")
pip3 install pydub

sudo apt-get update  
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:mc3man/trusty-media  
sudo apt-get install ffmpeg  

python3 convert.py