且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Python读取目录中的wav文件?

更新时间:2022-06-07 23:51:10

使用glob模块并向其传递一个模式(例如*.wav或任何命名的文件).它将返回符合条件或模式的文件列表.

Use the glob module and pass to it a pattern (like *.wav or whatever the files are named). It will return a list of files that match the criteria or the pattern.

import glob
from scipy.io.wavfile import read

wavs = []
for filename in glob.glob('*.wav'):
    print(filename)
    wavs.append(read(filename))