tclassp - tclassp - Advanced Speech Signal Processing Tools
This package provides tcl bindings for libassp, the Advanced Speech Signal Processing Library by Michel Scheffers.
The assp (advanced speech signal processor) library aims at providing functionality for handling speech signal files in most common audio formats and for performing analyses common in phonetic science/speech science. These will include the calculation of formants, fundamental frequency, root mean square, auto correlation, a variety of spectral analyses, zero crossing rate, filtering etc.
tclassp's most important commands are basically wrappers for the two fundamental data structures in libassp namely data_objects (DOBJ) and anaysis_options (AOPTS). The corresponding tclassp commands are therefore called ::tclassp::object and ::tclassp::option. DOBJs are used to read and write and store various audio file formats as well as some formats used for storing parametrical data, most importantly Simple Signal file Format (SSFF) which is also the output format of most analysis procedures. AOPTS are used to handle (store and validate) analysis processing options. tclassp predefines a number of instances of ::tclassp::option for those analysis procedures which are also implemented as command line programs in libassp, see below.
These variable store errors or warnings encountered during calls of the exec subcommands (see below). They will be reset at each new call of exec.
This command creates a new ASSP DOBJ structure with an associated Tcl command whose name is DOBJname from the signal file referred to by "signalFileName". The name of the newly created command is returned. If there already is a Tcl Command named DOBJname it will be (safely) deleted. This DOBJ command is explained in full detail in the sections DOBJ COMMAND and DOBJ METHODS. The object command will be created under the current namespace if the DOBJname is not fully qualified, and in the specified namespace otherwise.
This command will probably only rarely be used directly since the package predefines AOPTS commands for all analysis procedures in libassp, see PREDEFINED AOPTS COMMANDS. The command creates a new ASSP AOPTS structure with an associated Tcl command whose name is AOPTSname. The AOPTS structure will be tailored for the analysis procedure given in analysisFunction. analysisFunction maybe any one returned by ::tclassp::anafuncs, see below. This AOPTS command is explained in full detail in the sections AOPTS COMMAND, COMMON AOPTS OPTIONS, and AOPTS METHODS. The object command will be created under the current namespace if the AOPTSname is not fully qualified, and in the specified namespace otherwise.
Returns a list of available analysis commands. Every available analysis command is already predefined, see PREDEFINED AOPTS COMMANDS.
Returns a simple list of the code names of the available window functions. See WINDOW FUNCTIONS for details.
Returns a nested list of details on the available window functions. See WINDOW FUNCTIONS for more information.
This command extracts signal data from the signal file given in "infile" and writes them to the file whose name is given in "outfile". Extraction starts at the time specified as start and ends at the time given in end. Both times must be specified in milli seconds. Specifying times outside the range will result in an error and no data will be written to "outfile". Beware that, if present, "outfile" will be overwritten without warning.
If verbosityLevel is specified, this command sets the verbosity level of the package to the given value. If verbosityLevel is not specified the current value is returned. The package author is not sure whether or how this command works...
This command returns a list of linear prediction types, see tclassp_rfcana for details.
This command returns a list of spctrum types, see tclassp_spectrum for details.
All commands created by ::tclassp::object have the following general form and may be used to invoke various operations on their data object.
The method method and its arg'uments determine the exact behavior of the command. See section DOBJ METHODS for the detailed specifications. DOBJ commands can be deleted safely using Tcl's rename mechanism.
% tclassp::object dobj "samplefile.wav" dobj % rename dobj ""
This command creates a new DOBJ which is an almost exact copy of the original DOBJname and returns the name of the new DOBJ. This name is either newName if specified, or it is generated automatically, see AUTOMATIC OBJECT NAMING for details. The copy will only differ from the original in terms of its internally stored file path.
This command extracts data from the currently selected track of a DOBJ. If the -start and -end sample numbers are not given or less or greater than the range of the data, they will be set to the start and the end of the data. Specifying a start sample greater than the end sample or vice versa will result in an error. The extracted data will either be returned or, if -channel is specified and chan is an open Tcl Channel (as returned by e.g. open) written to said channel. In the latter case, the number of samples transferred from the DOBJ to the channel will be returned. If -emuformat is specified with a segnum greater 0 the result will be formatted such that it can be stored as an EMU track list (see http://emu.sourceforge.net). segnum should then correspond to the segment number in an EMU segment list.
This command frees the memory allocated to store the signal data but does not delete the DOBJ itself.
This command applies the analysis function specified by a previously defined AOPTSname and the corresponding options to the data in DOBJname. The result is a new DOBJ named newName, if specified, otherwise a name is automatically assigned, see AUTOMATIC OBJECT NAMING for details. The command returns the name of the newly created object.
This command returns a key/value list of informations about the DOBJ, such as sampling rate, format, duration etc. The optional argument can be -all in which case information on all available tracks is returned or -track in which case only information on the currently selected track is returned. Defaults to -all. The following example uses a data object containing formant data and the corrsponding bandwidths.
% ::tclassp::object formants formants.fms formants % formants info file_name formants.fms file_format SSFF header_size 152 byte_order MSB_last data_rate 200.0 sample_rate 16000.0 number_frames 208 start_time 0.0025 duration {1.040 sec} ssff_keyword fm data_type {formant_frequency (Hz)} data_format INT16 number_fields 4 ssff_keyword bw data_type {formant_bandwidth (Hz)} data_format INT16 number_fields 4 % % formants info -track file_name formants.fms file_format SSFF header_size 152 byte_order MSB_last data_rate 200.0 sample_rate 16000.0 number_frames 208 start_time 0.0025 duration {1.040 sec} ssff_keyword fm data_type {formant_frequency (Hz)} data_format INT16 number_fields 4
This command returns a boolean value indicating whether the DOBJ currently contains unsaved data.
This command returns the value of the OriginalFreq field currently only available in SSFF. If this field is not present, 0 is returned. The OriginalFreq field can be present in parametric data files (e.g. spectral data) and states the sampling rate of the original signal file on which an analysis has been run. This information is especially useful for spectral data.
If values are not specified this command returns the value(s) of the sample spacified as sampleNumber. If values are specified there should be one value per channel in the currently selected track. A value specified as "?" will not be changed. The following example uses formant data with 4 channels (F1-F4).
% ::tclassp::object formants formants.fms formants % formants sample 39 367 2046 2407 3524 % formants sample 39 370 2050 2410 3520 % formants sample 39 370 2050 2410 3520 % formants sample 39 ? 0 0 ? % formants sample 39 370 0 0 3520 % formants needssave 1
If newTrack is not specified, this command returns the currently selected track. At creation time, the first track encountered in the signal file is selected. If newTrack is specified, it must be a valid track of the DOBJ. The command returns the empty string on success or an error.
% ::tclassp::object formants formants.fms formants % formants track fm % formants track bw % formants track bw
This command returns a list of all available tracks in the DOBJ.
% ::tclassp::object formants formants.fms formants % formants track fm bw
This command writes the contents of a DOBJ to file. If the DOBJ internally has a file path (i.e. because it was vcreated from a file or has been written to already) the "filename" argument needs not be specified. If the DOBJ does not internally have a file path (i.e. because it was created by e.g. the copy or the exec subcommands) "filename" argument must be specified or else the command will return with an error.
All commands created by ::tclassp::option have the following general form and may be used to invoke various operations on their data object.
The method method and its arg'uments determine the exact behavior of the command. See section AOPTS METHODS for the detailed specifications. AOPTS commands can be deleted safely using Tcl's rename mechanism.
% ::tclassp::option aopt rmsana aopt % rename aopt ""
Returns the current setting of the option option. option may be any option appropraite for the underlying analysis function, see COMMON AOPTS OPTIONS and PREDEFINED AOPTS COMMANDS below.
For each option-value pair sets option to value. If the last option is missing its corresponding value the current value is returned. option may be any option appropraite for the underlying analysis function, see COMMON AOPTS OPTIONS and PREDEFINED AOPTS COMMANDS below.
Currently not standard behaviour, will be changed
Performs the ASSP analysis function specified at creation time on all files whose names are given in FileNameList. FileNameList must be a proper Tcl list. Returns the number of files processed successfully
This command returns a list of information on the AOPTS command. The first three elements of the list are
the name of the analysis function
the major version number
the minor version number
The remaining elements consist of key-value pairs listing all available options of the analysis function and the the option type. Option type is useful for the creation of graphical user interfaces and may be:
bool: Options with a boolean value, best represented with check boxes
text: Options with a more or less free value, best represented with entry fields
radio: Options with a short range of fixed values, best represented by radio buttons
combo: Options with longer ranges of fixed values, best represented by combo boxes
spin: Options with continuos numerical value ranges, best represented by spin boxes
tkassp makes use of these otpion types to generate GUIs more or less automatically. In some cases, option type is the empty string to indicate that the option is not to be used in a GUI in the same way as the other options, see COMMON AOPTS OPTIONS for details.
Resets all options to the default.
Returns the version of the ASSP analysis function.
The following options do not affect the resulting analysis. They do not have an option type as defined for the AOPTSname info command. These options are available for all analysis commands.
Defines the value of the output extension when the analysis result is written to file.
Defines the directory in which the resulting file (if any) is stored.
If counterVariable is a fully qualified variable name, it is incremented each time the AOPTSname exec command finishes processing a file. This is useful to track the progress of the analysis especially for long file lists. If counterVariable is empty (the default) no counting is performed.
If stopVariable is a fully qualified variable name, it is read each time the AOPTSname exec command start processing a file. Setting stopVariable to true will cause the abortion of the running AOPTSname exec command. This is useful if the necessity to abort time-consuming processes of of long file lists should arise. If stopVariable is the empty string (the default) aborting processes is not possible.
The following options will affect the results of the anaysis functions. Some are available in all ASSP analysis functions but not in all of them:
Start time of the analysis in ms. Defaults to begin of signal.
End time of the analysis in ms. Defaults to end of signal.
If useCenterTime is true, a single frame analysis with the analysis window centered at the time specified in -begin will be performed. Overrules specifications of -end and -winShift. Defaults to false.
Specifies the length of the anaysis window in ms.
Boolean value determining whether -winSize is interpreted as the effective or as the exact length of the analysis window.
Specifies the size of the window shift in ms.
Specifies the code name of the window function to use. Valid window functions are listed in WINDOW FUNCTIONS.
There is a number of options not listed here which are used in few functions only. They are documented in the context were they occur, i.e. in the manual pages of the corresponding functions.
The assp library provides a number of predefined analysis commands which can be listed with the ::tclassp::anacomds commands. The following tclassp commands implement these functions. They are documented in separate manual pages:
::tclassp::acfana computes the autocorrelation function. Manual page: tclassp_acfana
::tclassp::afdiff differentiates a signal. Manual page: tclassp_afdiff
::tclassp::affilter filters a signal. Manual page: tclassp_affilter
::tclassp::f0ana calculates the fundamental frequency of a signal. Manual page: tclassp_f0ana
::tclassp::forest estimates formants of a signal and their bandwidthes. Manual page: tclassp_forest
::tclassp::mhspitch calculates the pitch of a signal. Manual page: tclassp_mhspitch
::tclassp::rfcana calculates a signals reflection coefficients. Manual page: tclassp_rfcana
::tclassp::rmsana calculates the Root Mean Square of a signal. Manual page: tclassp_rmsana
::tclassp::spectrum performs spectral analyses of a signal. Manual page: tclassp_spectrum
::tclassp::zcrana computes the zero-crossing rate of a signal. Manual page: tclassp_zcrana
The complete list of window functions and their properties at the time of writing is the following (codename, description, effective length, side lobes (< X dB), roll-off (dB/oct)):
{RECTANGLE rectangle 1.0 -13.26 -6.0}
{PARABOLA parabola/Riesz/Welch 0.8333333333333334 -21.29 -12.0}
{COS cosine 0.8105694692281689 -23.0 -12.0}
{HANN Hann/hanning/cosine^2 0.6666666666666666 -31.47 -18.0}
{COS_4 cosine^4 0.5142857154612245 -46.74 -30.0}
{HAMMING Hamming 0.7337695010893505 -42.67 -6.0}
{BLACKMAN Blackman 0.5791201574544315 -58.11 -18.0}
{BLACK_X {exact Blackman} 0.5904236995600665 -68.23 -6.0}
{BLACK_M3 {min. 3-term Blackman-Nuttal} 0.5869532673384601 -71.47 -6.0}
{BLACK_M4 {min. 4-term Blackman-Nuttal} 0.5060234885476891 -98.14 -6.0}
{NUTTAL_3 {3-term Nuttal (-18 dB/oct)} 0.5642936394271199 -64.19 -18.0}
{NUTTAL_4 {4-term Nuttal (-18 dB/oct)} 0.49474761583350296 -93.32 -18.0}
{KAISER2_0 {Kaiser-Bessel (alpha = 2.0)} 0.6682964188668098 -45.85 -6.0}
{KAISER3_0 {Kaiser-Bessel (alpha = 3.0)} 0.5570301132930179 -69.62 -6.0}
{KAISER4_0 {Kaiser-Bessel (alpha = 4.0)} 0.48701841932395973 -94.41 -6.0}
Some commands create new DOBJs and may have to name them automatically. Automatic names ar created in the form dobjX where X is the smallest available integer. Tcl commands that are already present in the interpreter will not be overwritten, i.e. given that dobj0, dobj1, and dobj4 exist, the resulting name would be dobj3.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tclassp of the ASSP Library Tracker. Please also report any ideas for enhancements you may have for either package and/or documentation.
tclassp_acfana, tclassp_afdiff, tclassp_affilter, tclassp_f0ana, tclassp_forest, tclassp_mhspitch, tclassp_rfcana, tclassp_rmsana, tclassp_spectrum, tclassp_zcrana
Copyright © 2007-2012 Lasse Bombien <lasselasse@users.sourceforge.net>