Hi I am new to python and i am trying to write a program that would classify an audio file.
My data set is in google drive and I am writing my code in google colab.
All of the audio files (.wav) which I want to analyze or stored in my google drive under folder name "wavdata"
1) The first problem i have is :
for fname in os.listdir(DATA_DIR):
-- this keeps getting me error.
2) Second problem i have is:
try : --> syntax error.
Could someone please help me?
Thank you!
My data set is in google drive and I am writing my code in google colab.
All of the audio files (.wav) which I want to analyze or stored in my google drive under folder name "wavdata"
Python:
from google.colab import drive
drive.mount("/content/drive")
Python:
DATA_DIR = '/content/drive/My Drive.wavdata/'
Python:
for fname in os.listdir(DATA_DIR):
try:
if '.wav' not in fname or 'dima' in fname:
continue
struct = fname.split('_')
digit = struct[0]
patient = struct[1]
wav, sr = librosa.load(DATA_DIR + fname)
padded_x = pad1d(wav, 30000)
spectrogram = np.abs(librosa.stft(wav))
mel_spectrogram = librosa.feature.melspectrogram(wav)
mfcc = librosa.feature.mfcc(wav)
if patient == test_patient:
test_x.append(padded_x)
test_spectrograms.append(spectrogram)
test_mel_spectrograms.append(mel_spectrogram)
test_mfccs.append(mfcc)
test_y.append(digit)
else:
train_x.append(padded_x)
train_spectrograms.append(spectrogram)
train_mel_spectrograms.append(mel_spectrogram)
train_mfccs.append(mfcc)
train_y.append(digit)
except Exception as e:
print(fname,e)
raise
1) The first problem i have is :
for fname in os.listdir(DATA_DIR):
-- this keeps getting me error.
2) Second problem i have is:
try : --> syntax error.
Could someone please help me?
Thank you!