# HG changeset patch
# User tomwalters
# Date 1266862634 0
# Node ID 921575ec87a3d2e256ff7be90306fc681786aad3
# Parent aeac9e2151c603969c16aa187fc312f157f9ac77
- Added scripts directory with a few basic scripts for testing modules and interfacting with matlab
diff -r aeac9e2151c6 -r 921575ec87a3 trunk/src/Scripts/Features_test.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/Scripts/Features_test.py Mon Feb 22 18:17:14 2010 +0000
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# AIM-C: A C++ implementation of the Auditory Image Model
+# http://www.acousticscale.org/AIMC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+"""
+Profiles_test.py
+
+Created by Thomas Walters on 2010-02-22.
+Copyright 2010 Thomas Walters
+Test the AIM-C model from filterbank to SSI profiles
+"""
+
+import aimc
+from scipy.io import wavfile
+from scipy import io
+import scipy
+import pylab
+from itertools import izip, chain, repeat
+
+def grouper(n, iterable, padvalue=None):
+ "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
+ return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
+
+def main():
+ wave_path = "/Users/Tom/Documents/Work/PhD/HTK-AIM/Sounds/"
+ features_path = "/Users/Tom/Documents/Work/PhD/HTK-AIM/work08-jess-original-rec_rubber/features/"
+
+ file_name = "aa/aa161.1p119.4s100.0t+000itd"
+
+ wave_suffix = ".wav"
+ features_suffix = ".mat"
+
+ frame_period_ms = 10;
+
+ wave_filename = wave_path + file_name + wave_suffix
+ features_filename = features_path + file_name + features_suffix
+
+ (sample_rate, input_wave) = wavfile.read(wave_filename)
+ wave_length = input_wave.size
+ buffer_length = int(frame_period_ms * sample_rate / 1000)
+
+ #pylab.plot(input_wave)
+ #pylab.show()
+
+ input_sig = aimc.SignalBank()
+ input_sig.Initialize(1, buffer_length, sample_rate)
+ parameters = aimc.Parameters()
+ parameters.Load("src/Scripts/profile_features.cfg")
+ mod_gt = aimc.ModuleGammatone(parameters)
+ mod_hl = aimc.ModuleHCL(parameters)
+ mod_profile = aimc.ModuleSlice(parameters)
+ mod_scaler = aimc.ModuleScaler(parameters)
+ mod_features = aimc.ModuleGaussians(parameters)
+ mod_gt.AddTarget(mod_hl)
+ mod_hl.AddTarget(mod_profile)
+ mod_profile.AddTarget(mod_scaler)
+ mod_scaler.AddTarget(mod_features)
+ mod_gt.Initialize(input_sig)
+
+ correct_count = 0;
+ incorrect_count = 0;
+
+ scaled_wave = []
+ for sample in input_wave:
+ scaled_wave.append(float(sample / float(pow(2,15) - 1)))
+ i = 0
+
+ wave_chunks = grouper(buffer_length, scaled_wave, 0)
+
+ out_frames = []
+ for chunk in wave_chunks:
+ i = 0
+ for sample in chunk:
+ input_sig.set_sample(0, i, float(sample))
+ i += 1
+ mod_gt.Process(input_sig)
+ out_sig = mod_features.GetOutputBank()
+
+ channel_count = out_sig.channel_count()
+ out_buffer_length = out_sig.buffer_length()
+ cfs = scipy.zeros((channel_count))
+ out = scipy.zeros((channel_count, out_buffer_length))
+
+ for ch in range(0, channel_count):
+ for i in range(0, out_buffer_length):
+ out[ch, i] = out_sig.sample(ch, i)
+ out_frames.append(out)
+
+ outmat = dict(profile_out=out_frames)
+ io.savemat("src/Scripts/features_out.mat", outmat)
+
+ pass
+
+
+if __name__ == '__main__':
+ main()
diff -r aeac9e2151c6 -r 921575ec87a3 trunk/src/Scripts/Profiles_test.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/Scripts/Profiles_test.py Mon Feb 22 18:17:14 2010 +0000
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# AIM-C: A C++ implementation of the Auditory Image Model
+# http://www.acousticscale.org/AIMC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+"""
+Profiles_test.py
+
+Created by Thomas Walters on 2010-02-22.
+Copyright 2010 Thomas Walters
+Test the AIM-C model from filterbank to SSI profiles
+"""
+
+import aimc
+from scipy.io import wavfile
+from scipy import io
+import scipy
+import pylab
+from itertools import izip, chain, repeat
+
+def grouper(n, iterable, padvalue=None):
+ "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
+ return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
+
+def main():
+ wave_path = "/Users/Tom/Documents/Work/PhD/HTK-AIM/Sounds/"
+ features_path = "/Users/Tom/Documents/Work/PhD/HTK-AIM/work08-jess-original-rec_rubber/features/"
+
+ file_name = "aa/aa161.1p119.4s100.0t+000itd"
+
+ wave_suffix = ".wav"
+ features_suffix = ".mat"
+
+ frame_period_ms = 10;
+
+ wave_filename = wave_path + file_name + wave_suffix
+ features_filename = features_path + file_name + features_suffix
+
+ (sample_rate, input_wave) = wavfile.read(wave_filename)
+ wave_length = input_wave.size
+ buffer_length = int(frame_period_ms * sample_rate / 1000)
+
+ #pylab.plot(input_wave)
+ #pylab.show()
+
+ input_sig = aimc.SignalBank()
+ input_sig.Initialize(1, buffer_length, sample_rate)
+ parameters = aimc.Parameters()
+ parameters.Load("src/Scripts/profile_features.cfg")
+ mod_gt = aimc.ModuleGammatone(parameters)
+ mod_hl = aimc.ModuleHCL(parameters)
+ mod_profile = aimc.ModuleSlice(parameters)
+ mod_scaler = aimc.ModuleScaler(parameters)
+ mod_gt.AddTarget(mod_hl)
+ mod_hl.AddTarget(mod_profile)
+ mod_profile.AddTarget(mod_scaler)
+ mod_gt.Initialize(input_sig)
+
+ correct_count = 0;
+ incorrect_count = 0;
+
+ scaled_wave = []
+ for sample in input_wave:
+ scaled_wave.append(float(sample / float(pow(2,15) - 1)))
+ i = 0
+
+ wave_chunks = grouper(buffer_length, scaled_wave, 0)
+
+ out_frames = []
+ for chunk in wave_chunks:
+ i = 0
+ for sample in chunk:
+ input_sig.set_sample(0, i, float(sample))
+ i += 1
+ mod_gt.Process(input_sig)
+ out_sig = mod_scaler.GetOutputBank()
+
+ channel_count = out_sig.channel_count()
+ out_buffer_length = out_sig.buffer_length()
+ cfs = scipy.zeros((channel_count))
+ out = scipy.zeros((channel_count, out_buffer_length))
+
+ for ch in range(0, channel_count):
+ for i in range(0, out_buffer_length):
+ out[ch, i] = out_sig.sample(ch, i)
+ out_frames.append(out)
+
+ outmat = dict(profile_out=out_frames)
+ io.savemat("src/Scripts/profile_out.mat", outmat)
+
+ pass
+
+
+if __name__ == '__main__':
+ main()
diff -r aeac9e2151c6 -r 921575ec87a3 trunk/src/Scripts/aa161p119s100t.wav
Binary file trunk/src/Scripts/aa161p119s100t.wav has changed
diff -r aeac9e2151c6 -r 921575ec87a3 trunk/src/Scripts/profile_features.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/Scripts/profile_features.cfg Mon Feb 22 18:17:14 2010 +0000
@@ -0,0 +1,8 @@
+gtfb.channel_count=200
+gtfb.min_frequency=86.0
+gtfb.max_frequency=16000.0
+nap.do_lowpass=true
+nap.lowpass_cutoff=100.0
+slice.temporal=false
+slice.all=true
+slice.normalize=true
\ No newline at end of file