I have one main folder that contain of 20 sub-folders. And any sub-folders have 6 sub-folders again (20 speaker, any speaker voice (*.wav) classifieds to 6 class).
I want to read all of *.wav files and feature extraction. feature extraction is input of my training model for Neural Network.
How can i read and feature extraction of all .wav files?
All of classes must training together? how?
My code for reading wav files from main folder as follows (but this code read only one sub-folder):
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)
And for feature extraction i use this code ( i want feature extraction for all of my sub-folders and wav files):
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)
I'm so confused. Please help me how can i do, step by step.
Thanks.
glob
is even better when used withpathlib.Path
.yields