Permalink
Browse files

isolated matlab_htk from original monolithic ronw-matlab-tools reposi…

…tory
  • Loading branch information...
ronw committed Jan 6, 2010
1 parent e14a6df commit 090e264cf579e115db3be29715700dd4934feefa
Showing with 82 additions and 3,681 deletions.
  1. +82 −16 README
  2. 0 {matlab_htk → }/apply_mllr_transform.m
  3. +0 −6 celltools/@lazymap/display.m
  4. +0 −7 celltools/@lazymap/end.m
  5. +0 −3 celltools/@lazymap/iscell.m
  6. +0 −59 celltools/@lazymap/lazymap.m
  7. +0 −3 celltools/@lazymap/length.m
  8. +0 −3 celltools/@lazymap/numel.m
  9. +0 −15 celltools/@lazymap/set.m
  10. +0 −7 celltools/@lazymap/size.m
  11. +0 −17 celltools/@lazymap/subsref.m
  12. +0 −5 celltools/README
  13. +0 −14 celltools/cellcat.m
  14. +0 −35 celltools/cfilter.m
  15. +0 −25 celltools/crange.m
  16. +0 −31 celltools/czip.m
  17. +0 −39 celltools/flatten.m
  18. +0 −61 celltools/glob.m
  19. +0 −38 celltools/interleave.m
  20. +0 −45 celltools/map.m
  21. +0 −45 celltools/mapreduce.m
  22. +0 −51 celltools/reduce.m
  23. +0 −46 celltools/sfilter.m
  24. 0 {matlab_htk → }/compose_hmms.m
  25. 0 {matlab_htk → }/eval_htk_recognizer.m
  26. 0 {matlab_htk → }/get_htk_path.m
  27. 0 {matlab_htk → }/get_temp_filename.m
  28. +0 −60 hmm/README
  29. +0 −129 hmm/adapt_gmm.m
  30. +0 −67 hmm/convert_hmm_to_gaussian_emissions.m
  31. +0 −218 hmm/decode_hmm.m
  32. +0 −54 hmm/eval_gmm.m
  33. +0 −195 hmm/eval_hmm.m
  34. +0 −82 hmm/is_valid_gmm.m
  35. +0 −133 hmm/is_valid_hmm.m
  36. +0 −67 hmm/lmvnpdf.m
  37. +0 −113 hmm/merge_states.m
  38. +0 −56 hmm/reorder_states.m
  39. +0 −24 hmm/sample_gaussian.m
  40. +0 −34 hmm/sample_gmm.m
  41. +0 −61 hmm/sample_hmm.m
  42. +0 −101 hmm/train_gmm.m
  43. 0 {matlab_htk → }/htkread.m
  44. 0 {matlab_htk → }/htkwrite.m
  45. 0 {matlab_htk → }/kmeans.m
  46. 0 {matlab_htk → }/learn_mllr_transform.m
  47. 0 {hmm → }/logsum.m
  48. +0 −77 matlab_htk/README
  49. +0 −15 matlab_htk/logsum.m
  50. +0 −288 plottools/add_pan_and_zoom_controls_to_figure.m
  51. +0 −24 plottools/align_axes.m
  52. +0 −34 plottools/plot_on_same_axes.m
  53. +0 −39 plottools/plot_or_imagesc.m
  54. +0 −134 plottools/plot_pages.m
  55. +0 −387 plottools/plotall.m
  56. +0 −422 plottools/zooming_scrollbar.m
  57. +0 −132 process_options.m
  58. 0 {matlab_htk → }/read_htk_hmm.m
  59. 0 {matlab_htk → }/read_text_file.m
  60. +0 −164 source_sep/maxvq_bb.m
  61. 0 {matlab_htk → }/train_gmm_htk.m
  62. 0 {matlab_htk → }/train_hmm_htk.m
  63. 0 {matlab_htk → }/train_htk_recognizer.m
  64. 0 {matlab_htk → }/train_htk_recognizer.sh
  65. 0 {matlab_htk → }/write_htk_bnf.m
  66. 0 {matlab_htk → }/write_htk_hmm.m
  67. 0 {matlab_htk → }/write_htk_slf.m
  68. 0 {matlab_htk → }/write_text_file.m
View
98 README
@@ -1,17 +1,83 @@
-This directory contains a variety of Matlab functions that I've found
-to be useful for my work at LabROSA. The portions written by me are
-distributed under the terms of the GNU General Public License. See
-the file COPYING for details.
-
-Contents:
-hmm - functions for evaluating hidden Markov models and Gaussian
- mixture models
-matlab_htk - functions that interface with the HTK Speech Recognition
- Toolkit (http://htk.eng.cam.ac.uk/) for training
- HMMs, GMMs and simple speech recognizers
-source_sep - implementations of standard algorithms for source
- separation
-celltools - useful functional programming style functions for cell arrays
-plottools - Wrappers around basic plotting functions and code for some
- handy new GUI controls.
+This package contains a set of functions for calling interfacing with
+HTK from Matlab. Right now its mostly limited to training GMMs and
+HMMs. It converts your Matlab data into a format that HTK understands
+and calls HTK command line programs. The path to the HTK binaries is
+hardcoded in get_htk_path.m
+The portions written by me are distributed under the terms of the GNU
+General Public License. See the file COPYING for details.
+
+Unforuntately this has not been very thoroughly tested, but it has
+been working for me. If anyone wants to write some unit tests using
+http://mlunit.sf.net or something similar I won't say no.
+
+
+* Functions
+
+They are all reasonably commented...
+
+ - The important ones:
+ - train_hmm_htk - use HTK to train an HMM
+ - train_gmm_htk - use HTK to train a GMM
+ - train_htk_recognizer - train a simple HTK recognizer
+ - eval_htk_recognizer - recognize signal using HTK recognizer
+
+ - Utility functions:
+ - read_htk_hmm - read in an HTK HMM definition (text format only)
+ - write_htk_hmm - write an HMM structure as an HTK HMM definition
+ - htkread/htkwrite - read/write a Matlab matrix in HTK feature file format
+ (written by Mark Hasegawa-Johnson)
+ - compose_hmms - does FSM composition to form a big HMM from many
+ small HMMs (i.e. get an HMM to recognize a
+ sentence from a bunch of phone HMMs).
+ - kmeans - uses k-means to learn clusters from data. Used to
+ initialize GMMs and HMMs.
+ - logsum - takes the sum of a matrix of log likelihoods
+ - get_htk_path - centralized location to set the path to the HTK binaries
+
+* Data Structures
+
+The functions in this toolbox pass around the following structures:
+Note: all probabilities are stored as log probabilities
+
+** GMM
+ - gmm.nmix - number of components in the mixture
+ - gmm.priors - array of prior log probabilities over each state
+ - gmm.means - matrix of means (column x is mean of component x)
+ - gmm.covars - matrix of covariance (column x is the diagonal of the
+ covariance matrix of component x)
+
+** HMM with GMM observations
+ - hmm.name -
+ - hmm.nstates - number of states in the HMM
+ - hmm.emission_type - 'GMM'
+ - hmm.start_prob - array of log probs P(first observation is state x)
+ - hmm.end_prob - array of log probs P(last observation is state x)
+ - hmm.transmat - matrix of transition log probs (transmat(x,y)
+ = log(P(transition from state x to state y)))
+ - hmm.labels - optional cell array of labels for each state in the HMM
+ (for use in composing HMMs)
+ - hmm.gmms - array of GMM structures
+
+** HMM with Gaussian observations
+ - hmm.nstates - number of states in the HMM
+ - hmm.emission_type - 'gaussian'
+ - hmm.start_prob - array of log probs P(first observation is state x)
+ - hmm.end_prob - array of log probs P(last observation is state x)
+ - hmm.transmat - matrix of transition log probs (transmat(x,y)
+ = log(P(transition from state x to state y)))
+ - hmm.labels - optional cell array of labels for each state in the HMM
+ (for use in composing HMMs)
+ - hmm.means - matrix of means (column x is mean of state x)
+ - hmm.covars - matrix of means (column x is the diagonal of the
+ covariance matrix of component x)
+
+Note that each row of exp(hmm.transmat) does not necessarily sum to 1
+because for each state x there is some probability
+(exp(hmm.exit_prob(x))) that the next transition will be to a
+non-emitting exit state (i.e. the current observation is the last
+observation in the sequence). The correct invariant is:
+sum(exp(hmm.transmat, 2)) + exp(hmm.exit_prob) == ones(hmm.nstates, 1)
+
+
+2007-11-06 Ron Weiss <ronw@ee.columbia.edu>
File renamed without changes.
@@ -1,6 +0,0 @@
-function display(C)
-
-disp([inputname(1) ' = '])
-disp([' lazymap object:'])
-disp([' size: ' mat2str(size(C))])
-disp([' map function: ' func2str(C.func)])
View
@@ -1,7 +0,0 @@
-function e = end(C, k, n)
-
-if n == 1
- e = numel(C.cellarray);
-else
- e = size(C.cellarray, k);
-end
@@ -1,3 +0,0 @@
-function tf = iscell(C)
-
-tf = 1;
@@ -1,59 +0,0 @@
-function Y = lazymap(fun, C)
-% Y = lazymap(fun, C)
-%
-% Behaves like map/cellfun, but with lazy evaluation. Returns an
-% object that behaves like a cell array with same dimensions as C.
-% Whenever an element in y is referenced (e.g. y(10) or y{1:end}) the
-% function fun is applied to the corresponding cells of C and the
-% result is returned.
-%
-% Example:
-% numbers = {0, 0.5, 1, pi/2, pi, 2*pi};
-% y = lazymap(@cos, numbers);
-% y(10) % returns cos(numbers(4))
-% y = set(y, 'Function', @sin);
-% y{10} % returns sin(numbers(4))
-% y{1:5} % returns {sin(numbers(1)), sin(numbers(2)), ..., sin(numbers(5))}
-%
-% This lazy behavior is useful when only some elements of fun(C) are
-% needed at any given time. For example, when extracting features
-% from a set of files, a call like:
-% features = lazymap(@(x) compute_features(x, param1, param2), filenames)
-% can be used to give convenient access to the features of a large
-% data set without having to store all of it in memory.
-%
-% Note that this class doesn't support memoization so subsequent
-% references to the same element, e.g. y{1}; y{1};, will result in
-% multiple calls to fun(C{1}).
-%
-% 2007-11-01 ronw@ee.columbia.edu
-
-% Copyright (C) 2007 Ron J. Weiss
-%
-% 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 <http://www.gnu.org/licenses/>.
-
-if ~isa(fun, 'function_handle')
- error('1st argument must be a function handle')
-end
-
-if ~iscell(C)
- error('2nd argument must be a cell array.')
-end
-
-Y.cellarray = C;
-Y.func = fun;
-
-% Can't inherit from built in types...
-% y = class(y, 'lazymap', cellarray);
-Y = class(Y, 'lazymap');
@@ -1,3 +0,0 @@
-function n = length(C)
-
-n = length(C.cellarray);
@@ -1,3 +0,0 @@
-function n = numel(C, varargin);
-
-n = numel(C.cellarray, varargin{:});
View
@@ -1,15 +0,0 @@
-function C = set(C, varargin)
-
-propertyArgIn = varargin;
-while length(propertyArgIn) >= 2,
- prop = propertyArgIn{1};
- val = propertyArgIn{2};
- propertyArgIn = propertyArgIn(3:end);
-
- switch prop
- case 'Function'
- C.func = val;
- otherwise
- error('Invalid property')
- end
-end
@@ -1,7 +0,0 @@
-function varargout = size(C, dim)
-
-if nargin == 1
- [varargout{1:nargout}] = size(C.cellarray);
-else
- varargout{1} = size(C.cellarray, dim);
-end
@@ -1,17 +0,0 @@
-function varargout = subsref(C, S);
-
-if S.type == '.'
- error('Attempt to reference field of non-structure array.');
-end
-
-tmpS = S;
-tmpS.type = '()';
-B = subsref(C.cellarray, tmpS);
-B = cellfun(C.func, B, 'UniformOutput', 0);
-
-if S.type == '{}'
- varargout = B;
-else
- varargout{1} = B;
-end
-
View
@@ -1,5 +0,0 @@
-This package contains a set of standard functional programming tools
-that can be used on cell arrays. Contains implementations of map,
-reduce, filter (called cfilter so as not to conflict with the filter()
-function in the Signal Processing Toolbox), and lazymap which has the
-same semantics as map but uses lazy evaluation.
View
@@ -1,14 +0,0 @@
-function c = cellcat(varargin)
-% c = cellcat(c1, c2, c3, ..., cn)
-%
-% Concatenates the concents of each cell array c1, ..., cn into one
-% big cell array.
-
-c = {};
-for n = 1:length(varargin)
- tmp = varargin{n};
- if ~iscell(tmp)
- tmp = {tmp};
- end
- c = {c{:} tmp{:}};
-end
View
@@ -1,35 +0,0 @@
-function Y = cfilter(fun, C)
-% Y = cfilter(fun, C)
-%
-% Returns a cell array only containing elements of C for which fun(C{i}) == 1.
-%
-% 2007-11-06 ronw@ee.columbia.edu
-
-% Copyright (C) 2007 Ron J. Weiss
-%
-% 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 <http://www.gnu.org/licenses/>.
-
-if ~isa(fun, 'function_handle')
- error('1st argument must be a function handle')
-end
-
-if ~iscell(C)
- error('2nd argument must be a cell array.')
-end
-
-bool = zeros(size(C));
-for n = 1:numel(C)
- bool(n) = feval(fun, C{n});
-end
-Y = C(bool);
View
@@ -1,25 +0,0 @@
-function c = crange(arg1, arg2, arg3)
-% c = crange(last)
-% c = crange(first, last)
-% c = crange(first, step, last)
-%
-% Creates a cell array containing a range of numbers. Analagous to
-% c = first:step:last
-% but creates a cell array instead of a normal matlab matrix. If
-% either first or step are not specified, they each default to 1.
-
-if nargin == 1
- first = 1;
- step = 1;
- last = arg1;
-elseif nargin == 2
- first = arg1;
- step = 1;
- last = arg2;
-elseif nargin == 3
- first = arg1;
- step = arg2;
- last = arg3;
-end
-
-c = num2cell(first:step:last);
View
@@ -1,31 +0,0 @@
-function C = czip(varargin)
-% C = czip(cell1, cell2, cell3, ...)
-%
-% Like Python's zip function. Returns a cell array C containing a list of
-% cell arrays such that:
-% C{i} = {cell1{i}, cell2{i}, cell3{i}, ...}
-%
-% C is truncated to the length of the smallest of the input arrays.
-
-% Copyright (C) 2008 Ron J. Weiss
-%
-% 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 <http://www.gnu.org/licenses/>.
-
-len = mapreduce(@length, @(x,y) min(x,y), varargin);
-C = cell(len, 1);
-for l = 1:len
- for n = 1:nargin
- C{l}{n} = varargin{n}{l};
- end
-end
View
@@ -1,39 +0,0 @@
-function y = flatten(x)
-% y = flatten(x)
-%
-% Takes a cell array x that contains nested cell arrays and
-% flattens the contents into a single cell array.
-% E.g. flatten({1, {2, 3, {4}, 5}}) returns {1, 2, 3, 4, 5}
-
-% Copyright (C) 2007 Ron J. Weiss
-%
-% 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 <http://www.gnu.org/licenses/>.
-
-if ~iscell(x)
- error('flatten only works on cell arrays.');
-end
-
-y = inner_flatten(x);
-
-
-function y = inner_flatten(x)
-if ~iscell(x)
- y = {x};
-else
- y = {};
- for n = 1:length(x)
- tmp = inner_flatten(x{n});
- y = {y{:} tmp{:}};
- end
-end
Oops, something went wrong.

0 comments on commit 090e264

Please sign in to comment.