[英]When I try to open a wave file in pydub, it can't find the file. Why is this?
Here is what the terminal looks like: 这是终端的外观:
>>> from pydub import AudioSegment
>>> song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")
File "C:\Python27\lib\pydub\audio_segment.py", line 534, in from_wav
return cls.from_file(file, 'wav', parameters)
File "C:\Python27\lib\pydub\audio_segment.py", line 505, in from_file
p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Now, this file DEFINITELY DOES exist on my computer, and as far as I know I used the backslashes correctly. 现在,此文件肯定存在于我的计算机上,据我所知,我正确使用了反斜杠。 Why isn't Python able to find it? 为什么Python无法找到它?
Take a closer look at that traceback - it isn't your WAV file that isn't being found, it's an executable program (referred to by conversion_command
) that isn't found. 仔细看看该回溯-找不到WAV文件,找不到可执行文件(由conversion_command
引用)。 According to the Pydub docs, no external command is needed for WAV files, so I suspect that the file you have isn't actually a valid WAV. 根据Pydub文档,WAV文件不需要外部命令,因此我怀疑您拥有的文件实际上不是有效的WAV。 You could try following the instructions in the Pydub docs for installing its optional dependencies (libav, ffmpeg), in case the file is a valid file of a different format. 如果文件是其他格式的有效文件,则可以尝试按照Pydub文档中的说明安装其可选依赖项(libav,ffmpeg)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.