如何修复:TypeError:预期的 str、bytes 或 os.PathLike 对象,而不是 builtin_function_or_method

问题描述

我正在尝试通过 os.listdir()文件夹中创建 .wav 文件的列表,然后对它们重新采样。 因此,我收到此错误

path = os.fspath(path)
TypeError: expected str,bytes or os.pathLike object,not builtin_function_or_method

我在下面写了我的代码

path="C:/Users/....filename"
dirs=os.listdir(path)


for file in os.listdir(os.path.join(dirs,path)):
    if file.endswith(".wav"):
        y,sr = librosa.load(file,sr=44100)
        y_8k = librosa.resample(y,sr,8000)
        Y=(file)
        soundfile.write(Y,y_8k,8000)
        

else:
    continue

如果您能帮我解决这个问题,我将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)