首页 > 解决方案 > WinError 2: 使用 AudioSegment.from_file 时系统找不到指定的文件

问题描述

运行以下代码时出现错误:

from pydub import AudioSegment
import soundfile as sf

path_to_file=r"C:\Users\test.wav"
audio_signal, sample_rate = sf.read(path_to_file)

stereo_audio= AudioSegment.from_file(path_to_file)

在最后一行我收到以下错误:“FileNotFoundError:[WinError 2] 系统找不到指定的文件”

os.path.exists(path_to_file)返回True

我也尝试过stereo_audio= AudioSegment.from_file(r"C:\Users\test.wav")返回相同的错误。

有人可以帮我解决这个问题吗?我很感激任何帮助!谢谢

编辑:

我发现,我的 wav 文件在 float32 中。

[this](错误:未知格式:3(尝试读取音频 wavfile 时))是否意味着某些功能需要 int16?也许这就是为什么它不起作用?

标签: python-3.xpydubaudiosegment

解决方案


推荐阅读