我尝试用户输入路径和文件格式,并使用Pydub模块将指定路径中的所有文件转换为wav文件。我收到此错误:
文件" /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pydub/audio_segment.py" ;,第342行,来自from_file
引发CouldntDecodeError("解码失败.ffmpeg返回错误代码:{0}" .format(retcode)) pydub.exceptions.CouldntDecodeError:解码失败。 ffmpeg返回错误代码:1
import os
import glob
from pydub import AudioSegment
def AudioCon():
audio_dir = input('Enter the path of the audio to convert : ')
extension = input('Enter Audio File Format')
ex = ('*.' + extension)
os.chdir(audio_dir)
return convertphase(audio_dir,ex)
def convertphase(audio_dir,ex):
for x in ex:
for Audio in glob.glob(ex):
wav_filename = os.path.splitext(os.path.basename(Audio))[0] + '.wav'
AudioSegment.from_file(Audio).export(wav_filename, format='wav')
AudioCon()