Added duet_benchmarks folder for unit test values and saved MATLAB tests for later.
ADD
tests/duet_reference/duet_benchmarks/benchmark_delay.npy.REMOVED.git-id
+b8961c51100c8e3ccdba191febfd3c5a0c29b7c9
\ No newline at end of file

ADD
tests/duet_reference/duet_benchmarks/benchmark_stft_ch0.npy.REMOVED.git-id
+2bf76ec3b3b56bae442bad5e3a01a8c6a71aea1f
\ No newline at end of file

ADD
tests/duet_reference/duet_benchmarks/benchmark_stft_ch1.npy.REMOVED.git-id
+42996955d5e42a9b7d858c532ff6299c596dd565
\ No newline at end of file

ADD
tests/duet_reference/duet_benchmarks/benchmark_symmetric_atn.npy.REMOVED.git-id
+bdb5a75d2ffc4ad3e95b98bd776560560177d805
\ No newline at end of file

ADD
tests/duet_reference/duet_benchmarks/benchmark_wmat.npy.REMOVED.git-id
+f8fb481cc282f9c762c8fa40a2514d9c7982e403
\ No newline at end of file

MODIFY
tests/test_duet.py
tests/test_duet.py
@@ -22,25 +22,25 @@ class DuetUnitTests(unittest.TestCase):
# duet = nussl.Duet(signal, 3)
# duet.run()
- def test_duet_outputs(self):
- input_file_name = os.path.join('..', 'input', 'dev1_female3_inst_mix.wav')
- signal = nussl.AudioSignal(path_to_input_file=input_file_name)
- refact_duet = nussl.Duet(signal, num_sources=3)
- refact_duet_result = refact_duet.run()
- duet = nussl.Duet(signal, 3)
- nussel_duet_result = duet.run()
- assert refact_duet_result == nussel_duet_result
-
- @staticmethod
- def _load_matlab_results():
-
- f_mat_path = os.path.join('duet_reference', 'rickard_duet', 'fmat')
- tf1_path = os.path.join('duet_reference', 'rickard_duet', 'tf1')
- tf2_path = os.path.join('duet_reference', 'rickard_duet', 'tf2')
-
- fmat = scipy.io.loadmat(f_mat_path)['back'].T
- delay_mat = scipy.io.loadmat(delay_mat_path)['fore'].T
- return sym_atn_mat, delay_mat
+ # def test_duet_outputs(self):
+ # input_file_name = os.path.join('..', 'input', 'dev1_female3_inst_mix.wav')
+ # signal = nussl.AudioSignal(path_to_input_file=input_file_name)
+ # refact_duet = nussl.Duet(signal, num_sources=3)
+ # refact_duet_result = refact_duet.run()
+ # duet = nussl.Duet(signal, 3)
+ # nussel_duet_result = duet.run()
+ # assert refact_duet_result == nussel_duet_result
+ #
+ # @staticmethod
+ # def _load_matlab_results():
+ #
+ # f_mat_path = os.path.join('duet_reference', 'rickard_duet', 'fmat')
+ # tf1_path = os.path.join('duet_reference', 'rickard_duet', 'tf1')
+ # tf2_path = os.path.join('duet_reference', 'rickard_duet', 'tf2')
+ #
+ # fmat = scipy.io.loadmat(f_mat_path)['back'].T
+ # delay_mat = scipy.io.loadmat(delay_mat_path)['fore'].T
+ # return sym_atn_mat, delay_mat
def test_compute_spectrogram_1_channel(self):
# Test with one channel, should throw value error
@@ -54,23 +54,23 @@ class DuetUnitTests(unittest.TestCase):
def test_compute_spectrogram_wmat(self):
# Load MATLAB values
# f_mat_path = os.path.join('duet_reference', 'rickard_duet', 'fmat')
- tf1_path = os.path.join('duet_reference', 'rickard_duet', 'tf1')
- tf2_path = os.path.join('duet_reference', 'rickard_duet', 'tf2')
+ stft0_path = os.path.join('duet_reference', 'duet_benchmarks', 'benchmark_stft_ch0.npy')
+ stft1_path = os.path.join('duet_reference', 'duet_benchmarks', 'benchmark_stft_ch1.npy')
# fmat = scipy.io.loadmat(f_mat_path)['fmat']
- tf1_mat = scipy.io.loadmat(tf1_path)['tf1']
- tf2_mat = scipy.io.loadmat(tf2_path)['tf2']
+ benchmark_stft0 = np.load(stft0_path)
+ benchmark_stft1 = np.load(stft1_path)
path = os.path.join('..', 'Input', 'dev1_female3_inst_mix.wav')
signal = nussl.AudioSignal(path)
duet = nussl.Duet(signal, 3)
- duet.stft_params.window_length = 1024
- duet.stft_params.window_type = nussl.WINDOW_RECTANGULAR
- duet.stft_params.hop_length = duet.stft_params.window_length
+ # duet.stft_params.window_length = 1024
+ # duet.stft_params.window_type = nussl.WINDOW_RECTANGULAR
+ # duet.stft_params.hop_length = duet.stft_params.window_length
duet_sft0, duet_sft1, duet_wmat = duet._compute_spectrogram(duet.sample_rate)
- assert np.allclose(duet_sft0, tf1_mat, atol=1e-06)
- assert np.allclose(duet_sft1, tf2_mat, atol=1e-06)
+ assert np.all(benchmark_stft0 == duet_sft0)
+ assert np.all(benchmark_stft0 == duet_sft1)
# assert np.allclose(duet_wmat, fmat)
# def test_compute_atn_delay(self):

ADD
tests/test_duet_matlab.py
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from __future__ import division
+
+import unittest
+import nussl
+import numpy as np
+import scipy.io.wavfile as wav
+import scipy.io
+import os
+import warnings
+
+
+# import sys
+# sys.path.insert(1, 'C:\\Users\\danielfelixkim\\Documents\\GitHub\\InteractiveAudioLab\\nussl\\nussl')
+
+class DuetUnitTests(unittest.TestCase):
+ # def test_setup(self):
+ # input_file_name = os.path.join('..', 'Input', 'dev1_female3_inst_mix.wav')
+ # signal = nussl.AudioSignal(path_to_input_file=input_file_name)
+
+ # duet = nussl.Duet(signal, 3)
+ # duet.run()
+
+ def test_duet_outputs(self):
+ input_file_name = os.path.join('..', 'input', 'dev1_female3_inst_mix.wav')
+ signal = nussl.AudioSignal(path_to_input_file=input_file_name)
+ refact_duet = nussl.Duet(signal, num_sources=3)
+ refact_duet_result = refact_duet.run()
+ duet = nussl.Duet(signal, 3)
+ nussel_duet_result = duet.run()
+ assert refact_duet_result == nussel_duet_result
+
+ @staticmethod
+ def _load_matlab_results():
+ f_mat_path = os.path.join('duet_reference', 'rickard_duet', 'fmat')
+ tf1_path = os.path.join('duet_reference', 'rickard_duet', 'tf1')
+ tf2_path = os.path.join('duet_reference', 'rickard_duet', 'tf2')
+
+ fmat = scipy.io.loadmat(f_mat_path)['back'].T
+ delay_mat = scipy.io.loadmat(delay_mat_path)['fore'].T
+ return sym_atn_mat, delay_mat
+
+ def test_compute_spectrogram_1_channel(self):
+ # Test with one channel, should throw value error
+ num_samples = 100 # 1 second
+ np_sin = np.sin(np.linspace(0, 100 * 2 * np.pi, num_samples)) # Freq = 100 Hz
+ signal = nussl.AudioSignal(audio_data_array=np_sin)
+ with self.assertRaises(ValueError):
+ duet = nussl.Duet(signal, 3)
+ duet._compute_spectrogram(duet.sample_rate)
+
+ def test_compute_spectrogram_wmat(self):
+ # Load MATLAB values
+ # f_mat_path = os.path.join('duet_reference', 'rickard_duet', 'fmat')
+ tf1_path = os.path.join('duet_reference', 'rickard_duet', 'tf1')
+ tf2_path = os.path.join('duet_reference', 'rickard_duet', 'tf2')
+
+ # fmat = scipy.io.loadmat(f_mat_path)['fmat']
+ tf1_mat = scipy.io.loadmat(tf1_path)['tf1']
+ tf2_mat = scipy.io.loadmat(tf2_path)['tf2']
+
+ path = os.path.join('..', 'Input', 'dev1_female3_inst_mix.wav')
+ signal = nussl.AudioSignal(path)
+ duet = nussl.Duet(signal, 3)
+ duet.stft_params.window_length = 1024
+ duet.stft_params.window_type = nussl.WINDOW_RECTANGULAR
+ duet.stft_params.hop_length = duet.stft_params.window_length
+
+ duet_sft0, duet_sft1, duet_wmat = duet._compute_spectrogram(duet.sample_rate)
+ assert np.allclose(duet_sft0, tf1_mat, atol=1e-06)
+ assert np.allclose(duet_sft1, tf2_mat, atol=1e-06)
+ # assert np.allclose(duet_wmat, fmat)
+
+ # def test_compute_atn_delay(self):
+ # sym_atn_mat_path = os.path.join('duet_reference', 'rickard_duet', 'alpha_duet')
+ # delay_mat_path = os.path.join('duet_reference', 'rickard_duet', 'delta_duet')
+ # sym_atn_mat = scipy.io.loadmat(sym_atn_mat_path)['sym'].T
+ # delay_mat = scipy.io.loadmat(delay_mat_path)['delay'].T
+
+ # def test_make_histogram(self):
+
+ # def test_convert_peaks
+
+ # def test_compute_masks
+
+ # def test_convert_time_domain
+
+ # test_smooth_matrix
+
+
+if __name__ == '__main__':
+ unittest.main()
+

Added duet_benchmarks folder for unit test values and saved MATLAB tests for later.