Library Name: lib_algo.a
Introduction:
The Algorithm classes are used to implement most basic digital signal
processing (DSP) functions in speech recognition. This library contains
a collection of classes that are used as building blocks for creating
many industry-standard front end algorithms - the portion of a
speech recognition system that converts the audio signal to a feature
stream. These classes have also been designed to support many types
of basic DSP research and education.
Every class is designed to support multiple algorithms and
implementations. The underlying mathematical operations in these
classes can be accessed by selecting the appropriate algorithm
and implementation, and then invoking the compute method:
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
The interface is essentially a vector input/vector output interface
at this basic level.
The Algorithm classes have been designed to support a graphical
user interface (GUI) tool,
isip_transform_builder,
that allows algorithms to be implemented by simply drawing a flow chart
using the building blocks provided in this library. All classes
conform to a basic application programming interface (API)
which is described in the class named
AlgorithmBase
under the section titled
class-specific methods.
At the core of this interface is a method named apply:
boolean apply(Vector& output, const Vector< CircularBuffer >& input);
which produces output on a frame-by-frame basis.
AlgorithmData is a container class that hides the details of the
input data type from the programmer.
Each documentation page for an Algorithm class contains a table
defining all algorithms and implementations supported for that class.
For example, consider the table for the
Correlation class.
In the description section of this class, you will see the following
table:
The first two columns in this table define what specific algorithm
you will select. For example, to select a factored implementation
of the autocorrelation algorithm, you would place the following lines
in your code:
Correlation autoc;
autoc.setAlgorithm(Correlation::AUTO);
autoc.setImplementation(Correlation::UNFACTORED);
The equations governing this particular choice are given in the column
titled "Equation", and the parameters available for this choice
are given in the column titled "Parameters".
The third column in this table, titled "Mode", provides control over
whether the algorithm uses only data within the current frame, referred
to as "FRAME_INTERNAL", or whether the algorithm uses data from previous
and future frames, referred to as "CROSS_FRAME". Some classes, such
as the Statistics class, support accumulation of results across
many frames using a mode called "ACCUMULATE".
For some algorithms, such as correlation, the type of data
also determines what specific algorithm should be used.
The fourth and fifth columns in this table provide control over
the data types. For example, the autocorrelation algorithm
can operate on sampled data ("SIGNAL") and linear prediction
coefficients ("REFLECTION" and "PREDICTION"). Users can specify
the input data type using the setMode method:
Autocorrelation autoc;
autoc.setMode(Autocorrelation::REFLECTION);
The output data type is set automatically in the class based on the
input data type, and the algorithm and implementation settings. Two
special values for this data type specification are "GENERIC", which
means the algorithm will take any data as input, and "PROPAGATE",
which directs the class set the output the data type to the same
thing as the input data type.
This functionality, though a bit cumbersome to a typical user,
is required to allow tools such as
isip_transform_builder
to transparently process data. Most classes have default settings
that allow them to be used without too much setup or initialization.
Example:
To demonstrate the use of a compute method, let's begin with a simple
example:
01 // isip include files
02 //
03 #include <Energy.h>
04
05 // main program starts here:
06 // this example demonstrates the use of a compute method
07 //
08 int main(int argc, const char** argv) {
09
10 // declare an Energy object
11 //
12 Energy energy;
13
14 // declare the input and output vectors
15 //
16 VectorFloat input(L"1, 2, 1, 3, 4, 2, 3, 1");
17 VectorFloat output;
18
19 // set the algorithm implementation
20 //
21 energy.setAlgorithm(Energy::SUM);
22 energy.setImplementation(Energy::IDENTITY);
23
24 // compute the energy
25 //
26 energy.compute(output, input);
27
28 // output the input and output to the console
29 //
30 input.debug(L"input signal:");
31 output.debug(L"energy:");
32
33 // exit gracefully
34 //
35 Integral::exit();
36 }
Explanation:
In the above example, the declaration on line 12 creates a Energy object. On lines 16 and 17 we
create input signal and output energy as a VectorFloat object. Next,
on lines 21 and 22, we set the algorithm and implementation of the
Energy object as SUM and IDENTITY, respectively. After setting the
algorithm and implementation, we compute the energy of the input
signal on line 26.
Finally, lines 30 and 31 demonstrates how to send input signal and
output to the terminal using debug method. The output for this code
is the following:
<VectorFloat::input signal:> length_d = 8
<VectorFloat::input signal:> capacity_d = 8
<VectorFloat::input signal:> v_d = 1, 2, 1, 3, 4, 2, 3, 1
<VectorFloat::energy:> length_d = 1
<VectorFloat::energy:> capacity_d = 1
<VectorFloat::energy:> v_d = 45
The Algorithm classes that are currently available include:
The next level in the ISIP class hierarchy is
signal processing
which provides classes that produce feature streams from
information sources such as speech signals.
The software corresponding to the examples
demonstrated in this document can be found in our
documentation directory
under
class/sp/.