Home > voicebox > voicebox.m

voicebox

PURPOSE ^

VOICEBOX set global parameters for Voicebox functions Y=(FIELD,VAL)

SYNOPSIS ^

function y=voicebox(f,v)

DESCRIPTION ^

VOICEBOX  set global parameters for Voicebox functions Y=(FIELD,VAL)

  Inputs:  F   is a field name
           V   is a new value for the field

 Outputs:  Y   is set equal to the structure of parameters if the
               f and v inputs are both present or both absent. If only
               input f is specified, then y is set to the value of the
               corresponding field or null if it doesn't exist.

 You can override the defaults set here by setting the environment variable "VOICEBOX"
 to the path of an m-file that contains lines like "% PP.dir_temp='F:\TEMP';"

 This routine contains default values for constants that are used by
 other functions in the VOICEBOX toolbox. Values in the first section below,
 entitled "System-dependent directory paths" should be set as follows:

    PP.dir_temp     directory for storing temporary files
    PP.dir_data     default directory to preappend to speech data file names
                    when the "d" option is specified in READWAV etc.
    PP.shorten      location of SHORTEN executable. SHORTEN is a proprietary file compression
                    algorithm that is used for some SPHERE-format files. READSPH
                    will try to call an external decoder if it is asked to
                    read such a compressed file.
    PP.sfsbin       location of Speech Filing Sysytem binaries. If the "c" option
                    is given to READSFS, it will try to create a requested item
                    if it is not present in the SFS file. This parameter tells it
                    where to find the SFS executables.
    PP.sfssuffix    suffix for Speech Filing Sysytem binaries. READSFS uses this paremeter
                    to create the name of an SFS executable (see PP.sfsbin above).
 Other values defined in this routine are the defaults for specific algorithm constants.
 If you want to change these, please refer to the individual routines for a fuller description.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y=voicebox(f,v)
0002 %VOICEBOX  set global parameters for Voicebox functions Y=(FIELD,VAL)
0003 %
0004 %  Inputs:  F   is a field name
0005 %           V   is a new value for the field
0006 %
0007 % Outputs:  Y   is set equal to the structure of parameters if the
0008 %               f and v inputs are both present or both absent. If only
0009 %               input f is specified, then y is set to the value of the
0010 %               corresponding field or null if it doesn't exist.
0011 %
0012 % You can override the defaults set here by setting the environment variable "VOICEBOX"
0013 % to the path of an m-file that contains lines like "% PP.dir_temp='F:\TEMP';"
0014 %
0015 % This routine contains default values for constants that are used by
0016 % other functions in the VOICEBOX toolbox. Values in the first section below,
0017 % entitled "System-dependent directory paths" should be set as follows:
0018 %
0019 %    PP.dir_temp     directory for storing temporary files
0020 %    PP.dir_data     default directory to preappend to speech data file names
0021 %                    when the "d" option is specified in READWAV etc.
0022 %    PP.shorten      location of SHORTEN executable. SHORTEN is a proprietary file compression
0023 %                    algorithm that is used for some SPHERE-format files. READSPH
0024 %                    will try to call an external decoder if it is asked to
0025 %                    read such a compressed file.
0026 %    PP.sfsbin       location of Speech Filing Sysytem binaries. If the "c" option
0027 %                    is given to READSFS, it will try to create a requested item
0028 %                    if it is not present in the SFS file. This parameter tells it
0029 %                    where to find the SFS executables.
0030 %    PP.sfssuffix    suffix for Speech Filing Sysytem binaries. READSFS uses this paremeter
0031 %                    to create the name of an SFS executable (see PP.sfsbin above).
0032 % Other values defined in this routine are the defaults for specific algorithm constants.
0033 % If you want to change these, please refer to the individual routines for a fuller description.
0034 
0035 % Bugs/Suggestions
0036 %    (1)  Could allow a * at the end of F to act as a wildcard and return/print a part structure
0037 
0038 %      Copyright (C) Mike Brookes 2003
0039 %      Version: $Id: voicebox.m 9702 2017-04-19 10:48:12Z dmb $
0040 %
0041 %   VOICEBOX is a MATLAB toolbox for speech processing.
0042 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0043 %
0044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0045 %   This program is free software; you can redistribute it and/or modify
0046 %   it under the terms of the GNU General Public License as published by
0047 %   the Free Software Foundation; either version 2 of the License, or
0048 %   (at your option) any later version.
0049 %
0050 %   This program is distributed in the hope that it will be useful,
0051 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0052 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0053 %   GNU General Public License for more details.
0054 %
0055 %   You can obtain a copy of the GNU General Public License from
0056 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0057 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0059 
0060 persistent PP
0061 if isempty(PP)
0062     
0063     % System-dependent directory paths and constants
0064     
0065     PP.dir_temp='F:\TEMP';                      % directory for storing temporary files
0066     PP.dir_data='E:\dmb\data\speech';           % default directory to preappend to speech data file names
0067     PP.shorten='C:\bin\shorten.exe';            % location of shorten executable
0068     PP.flac='C:\bin\flac.exe';                  % location of flac executable
0069     PP.sfsbin='F:\Program Files\SFS\Program';   % location of Speech Filing Sysytem binaries
0070     PP.sfssuffix='.exe';                        % suffix for Speech Filing Sysytem binaries
0071     PP.memsize=50e6;                            % Maximum amount of temporary memory to use (Bytes)
0072     
0073     % DYPSA glottal closure identifier
0074     
0075     PP.dy_cpfrac=0.3;           % presumed closed phase fraction of larynx cycle
0076     PP.dy_cproj=0.2;            % cost of projected candidate
0077     PP.dy_cspurt=-0.45;         % cost of a talkspurt
0078     PP.dy_dopsp=1;              % Use phase slope projection (1) or not (0)?
0079     PP.dy_ewdly=0.0008;         % window delay for energy cost function term [~ energy peak delay from closure] (sec)
0080     PP.dy_ewlen=0.003;          % window length for energy cost function term (sec)
0081     PP.dy_ewtaper=0.001;        % taper length for energy cost function window (sec)
0082     PP.dy_fwlen=0.00045;        % window length used to smooth group delay (sec)
0083     PP.dy_fxmax=500;            % max larynx frequency (Hz)
0084     PP.dy_fxmin=50;             % min larynx frequency (Hz)
0085     PP.dy_fxminf=60;            % min larynx frequency (Hz) [used for Frobenius norm only]
0086     PP.dy_gwlen=0.0030;         % group delay evaluation window length (sec)
0087     PP.dy_lpcdur=0.020;         % lpc analysis frame length (sec)
0088     PP.dy_lpcn=2;               % lpc additional poles
0089     PP.dy_lpcnf=0.001;          % lpc poles per Hz (1/Hz)
0090     PP.dy_lpcstep=0.010;        % lpc analysis step (sec)
0091     PP.dy_nbest=5;              % Number of NBest paths to keep
0092     PP.dy_preemph=50;           % pre-emphasis filter frequency (Hz) (to avoid preemphasis, make this very large)
0093     PP.dy_spitch=0.2;           % scale factor for pitch deviation cost
0094     PP.dy_wener=0.3;            % DP energy weighting
0095     PP.dy_wpitch=0.5;           % DP pitch weighting
0096     PP.dy_wslope=0.1;           % DP group delay slope weighting
0097     PP.dy_wxcorr=0.8;           % DP cross correlation weighting
0098     PP.dy_xwlen=0.01;           % cross-correlation length for waveform similarity (sec)
0099     
0100     % now see if an environment variable has been set
0101     
0102     if ispc()
0103         vbenv=winenvar('VOICEBOX');
0104         if exist(vbenv,'file');     % update with locally defined values if defined
0105             run(vbenv)
0106         end
0107     end
0108     
0109     % now check some of the key values for validity
0110     
0111     if exist(PP.dir_temp,'dir')~=7        % check that temp directory exists
0112         PP.dir_temp = winenvar('temp');     % else use windows temp directory
0113     end
0114     
0115     [fnp,fnn,fne]=fileparts(mfilename('fullpath'));
0116     if exist(PP.shorten)~=2        % check that shorten executable exists
0117         PP.shorten=fullfile(fnp,'shorten.exe'); % next try local directory
0118         if exist(PP.shorten)~=2        % check if it exists in local directory
0119             PP.shorten='shorten.exe'; % finally assume it is on the search path
0120         end
0121     end
0122     
0123     if exist(PP.flac)~=2        % check that flac executable exists
0124         PP.flac=fullfile(fnp,'flac.exe'); % next try local directory
0125         if exist(PP.flac)~=2        % check if it exists in local directory
0126             PP.flac='flac.exe'; % finally assume it is on the search path
0127         end
0128     end
0129     
0130 end
0131 if nargin==0
0132     if nargout==0
0133         % list all fields
0134         nn=sort(fieldnames(PP));
0135         cnn=char(nn);
0136         fprintf('%d Voicebox parameters:\n',length(nn));
0137         
0138         for i=1:length(nn);
0139             if ischar(PP.(nn{i}))
0140                 fmt='  %s = %s\n';
0141             else
0142                 fmt='  %s = %g\n';
0143             end
0144             fprintf(fmt,cnn(i,:),PP.(nn{i}));
0145         end
0146     else
0147         y=PP;
0148     end
0149 elseif nargin==1
0150     if isfield(PP,f)
0151         y=PP.(f);
0152     else
0153         y=[];
0154     end
0155 else
0156     if isfield(PP,f)
0157         PP.(f)=v;
0158         y=PP;
0159     else
0160         error(sprintf('''%s'' is not a valid voicebox field name',f));
0161     end
0162 end

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003