Commit 7378ccd8 authored by Jan Rudolf's avatar Jan Rudolf

ADD preprocessing for single file

parent f0ccd249
......@@ -11,6 +11,12 @@ DATASET_FILE = os.path.join(DATASET_FOLDER, 'input.mf')
DUMB_PREFIX = '/Users/sness/mirex2008/genres/'
def preprocess_sample(path, **kwargs):
audio_file, sr = librosa.load(path)
y, _ = librosa.effects.trim(audio_file)
return librosa.feature.mfcc(y=y, **kwargs)
def preprocess(n_mfcc):
output_folder = f'preprocessed_nmfcc_{n_mfcc}'
output_file = os.path.join(output_folder, 'data.csv')
......@@ -42,9 +48,7 @@ def preprocess(n_mfcc):
output_index.append((smart_relative_output_path, row['label']))
audio_file, sr = librosa.load(smart_relative_path)
y, _ = librosa.effects.trim(audio_file)
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=n_mfcc)
mfccs = preprocess_sample(smart_relative_path, n_mfcc=n_mfcc)
np.save(smart_relative_output_path, mfccs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment