Added a demo for nmf_mfcc.
MODIFY
demos/demo_nmf_mfcc.py
demos/demo_nmf_mfcc.py
@@ -6,17 +6,22 @@ import numpy as np
def main():
# Load input file
-
-
- input_file_name = os.path.join('..', 'input', 'dev1_female3_inst_mix.wav')
+ input_file_name = os.path.join('..', 'input', 'piano_and_synth_arp_chord_mono.wav')
signal = nussl.AudioSignal(path_to_input_file=input_file_name)
- # Set up DUET
- nmf_mfcc = nussl.NMF_MFCC(signal, num_sources= 3, num_templates=60, distance_measure="euclidean", num_iterations=50)
+ # make a directory to store output if needed
+ if not os.path.exists(os.path.join('..', 'Output/')):
+ os.mkdir(os.path.join('..', 'Output/'))
+ # Set up NMMF MFCC
+ nmf_mfcc = nussl.NMF_MFCC(signal, num_sources=2, num_templates=6, distance_measure="euclidean",
+ num_iterations=10, random_seed=0)
# and run
nmf_mfcc.run()
- nmf_mfcc.make_audio_signals()
+ sources = nmf_mfcc.make_audio_signals()
+ for i, source in enumerate(sources):
+ output_file_name = str(i) + '.wav'
+ source.write_audio_to_file(output_file_name)
if __name__ == '__main__':
main()

MODIFY
nussl/separation/nmf_mfcc.py
nussl/separation/nmf_mfcc.py
@@ -101,12 +101,12 @@ class NMF_MFCC(mask_separation_base.MaskSeparationBase):
self.labeled_templates = self.clusterer.labels_
# Extract sources from signal
- channel_masks = self.extract_masks(channel_stft, channel_templates_matrix, channel_activation_matrix)
+ channel_masks = self._extract_masks(channel_stft, channel_templates_matrix, channel_activation_matrix)
self.masks.append(channel_masks)
return self.masks
- def extract_masks(self, signal_stft, templates_matrix, activation_matrix):
+ def _extract_masks(self, signal_stft, templates_matrix, activation_matrix):
""" Creates binary masks from clustered templates and activation matrices
Parameters:
signal_stft (np.matrix): A 2D Numpy matrix containing the stft of the current channel

Added a demo for nmf_mfcc.