我有一个主文件夹,其中包含20个子文件夹。任何子文件夹都有6个子文件夹(20个扬声器,任何扬声器的声音(*.wav)分类为6类)。你知道吗
我想阅读所有的*.wav文件和特征提取。特征提取是我的神经网络训练模型的输入。你知道吗
如何读取和提取所有.wav文件的特征?你知道吗
所有的课程必须一起训练?怎样?你知道吗
从主文件夹读取wav文件的代码如下(但此代码仅读取一个子文件夹):
import os
import scipy.io.wavfile as wav
r_dir = '/my path/'
data = []
rate = []
for root,sub,files in os.walk(r_dir):
files = sorted(files)
for f in files:
s_rate, x = wav.read(os.path.join(root, f))
rate.append(s_rate)
data.append(x)
对于特征提取,我使用以下代码(我希望对所有子文件夹和wav文件进行特征提取):
from python_speech_features import fbank
import scipy.io.wavfile as wav
(rate,sig)=wav.read("/my path for one .wav file")
fbank_feat = fbank(sig,rate)
print(fbank_feat)
我很困惑。请帮助我怎么做,一步一步。你知道吗
谢谢。你知道吗
要读取目录和子目录中的所有*.wav文件,可以使用以下命令:
我的目录:
输出:
WAV数据:
glob
与pathlib.Path
一起使用时更好。你知道吗收益率
相关问题 更多 >
编程相关推荐