name: SegmentConcat
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a

>     #include <SegmentConcat.h>

>     SegmentConcat(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float floor);
>     boolean eq(const SegmentConcat& arg);
>     boolean setDimension(long dim);

quick start:

>     none. this class is not to be used in isolation. this provides the
>     base functionality for the isip_segment_concat utility.

description:
The SegmentConcat class is used to provide the base functionality for the isip_segment_concat utilty. Currently, three algorithms are supported:

- MIN_MAX - compute the min-max for each dimension of the feature-vectors.
- SEG_CONCAT - manipulate the feature vectors given the segmental information.
- SEG_CONCAT_SYMBOL - manuplate the feature vectors given the segmental information on a symbol (model) basis.

The two implementations supported for SEG_CONCAT and SEG_CONCAT_SYMBOL are:

- NONE
- NORMALIZE

The good reference for this functionalty is:

Aravind Ganapathiraju, "Support Vector Machines for Speech Recognition", , Ph.D Dissertation, May 2002.

dependencies:

- VectorFloat
- Sdb
- FeatureFile
- TranscriptionDatabase
- AudioDatabase
- MemoryManager

public constants:

- define the class name:

      static const String CLASS_NAME = L"SegmentConcat";

- define the algorithm choices:

      enum ALGORITHM { MIN_MAX = 0, SEG_CONCAT, SEG_CONCAT_SYMBOL, DEF_ALGORITHM = MIN_MAX };

- define the implementation choices:

      enum IMPLEMENTATION { NONE = 0, NORMALIZE, DEF_IMPLEMENTATION = NONE };

- define the static NameMap objects:

      static const NameMap ALGO_MAP(L"MIN_MAX, SEG_CONCAT");

      static const NameMap IMPL_MAP(L"NONE, NORMALIZE");

- define i/o related constants:

      static const String DEF_PARAM = L"";

      static const String PARAM_ALGORITHM = L"algorithm";

      static const String PARAM_IMPLEMENTATION = L"implementation";

- define default argument(s):

      none

error codes:

- error code indicating SegmentConcat class general error:

      static const long ERR = 50800;

protected data:

- data common to all algorithms and implementations:
  - define an algorithm name:

        ALGORITHM algorithm_d;

  - define an implementation name:

        IMPLEMENTATION implementation_d;

  - define the minimum and maximum of the input features in each dimension:

        Vector&th;VectorFloat> min_max_d;

        Filename min_max_file_d;

  - define the variables associated to the segmental feature generation

        VectorLong ratio_d;

        boolean duration_flag_d;

        String level_d;

  - define variables associated with output feature file

        Long dim_d;

        FeatureFile::FILE_TYPE input_type_d;

        FeatureFile::FILE_FORMAT input_format_d;

  - variables associated with output feature file

        FeatureFile::FILE_TYPE output_type_d;

        FeatureFile::FILE_FORMAT output_format_d;

        String output_directory_d;

        String output_extension_d;

        Long output_preserve_d;

        String output_suffix_d;

  - variables associated with the databases

        Filename audiodb_file_d;

        Filename transdb_file_d;

        AudioDatabase audiodb_d;

        TranscriptionDatabase transdb_d;

  - static memory manager:

        static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

      static boolean setDebug(Integral::DEBUG debug_level);

- other debug methods:

      boolean debug(const unichar* message) const;

- destructor/constructor(s):

      ~SegmentConcat();

      SegmentConcat(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);

      SegmentConcat(const SegmentConcat& arg);

- assign methods:

      boolean assign(const SegmentConcat& arg);

- operator= methods:

      SegmentConcat& operator= (const SegmentConcat& arg);

- i/o methods:

      long sofSize() const;

      boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;

      boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;

- equality methods:

      boolean eq(const SegmentConcat& arg) const;

- memory management methods:

      static void* operator new(size_t size);

      static void* operator new[](size_t size);

      static void operator delete(void* ptr);

      static void operator delete[](void* ptr);

      static boolean setGrowSize(long grow_size);

      boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);

class-specific public methods:

- set methods:

      boolean setAlgorithm(ALGORITHM algorithm);

      boolean setImplementation(IMPLEMENTATION implementation);

      boolean setDimension(long dim = DEF_DIMENSION);

      boolean setMinMax(Vector<VectorFloat>& min_max);

      boolean setMinMaxFile(const Filename& min_max_file);

      boolean setRatio(const VectorLong& ratio);

      boolean setDurationFlag(const boolean duration_flag);

      boolean setInputType(const FeatureFile::FILE_TYPE input_type = FeatureFile::DEF_FILE_TYPE));

      boolean setInputFormat(const FeatureFile::FILE_FORMAT input_format = FeatureFile::DEF_FILE_FORMAT));

      boolean setOutputType(const FeatureFile::FILE_TYPE output_type = FeatureFile::DEF_FILE_TYPE));

      boolean setOutputFormat(const FeatureFile::FILE_FORMAT output_format = FeatureFile::DEF_FILE_FORMAT));

      boolean setOutputDirectory(const String& new_dir);

      boolean setOutputExtension(const String& extension);

      boolean setOutputPreserve(const long preserve);

      boolean setOutputSuffix(const String& suffix);

      boolean setVerbosity(const Integral::DEBUG verbosity);

      boolean setAudioDatabaseFile(const Filename& audiodb_file);

      boolean setTransDatabaseFile(const Filename& transdb_file);

      boolean setLevel(const String& level);

- get methods:

      ALGORITHM getAlgorithm() const;

      IMPLEMENTATION getImplementation() const;

      long getDimension() const;

      Vector>VectorFloat< getMinMax() const;

      Filename getMinMaxFile() const;

      VectorLong getRatio() const;

      boolean getDurationFlag() const;

      FeatureFile::FILE_TYPE getInputType() const;

      FeatureFile::FILE_FORMAT getInputFormat() const;

      FeatureFile::FILE_TYPE getOutputType() const;

      FeatureFile::FILE_FORMAT getOutputFormat() const;

      String getOutputDirectory() const;

      String getOutputExtension() const;

      long getOutputPreserve() const;

      String getOutputSuffix() const;

      Filename getAudioDatabaseFile() const;

      Filename getTransDatabaseFile() const;

      String getLevel() const;

- computational methods:

      boolean compute(Sdb& sdb, Sdb& sdb_symbols);

private methods:

- method to compute minimun and maximum values in each dimension

      boolean computeMinMax(Sdb& sdb_features);

- method to compute concatenated segmental features on the input feature file basis

      boolean computeSegFeatures(Sdb& sdb_features);

- method to compute concatenated segmental features on the symbol (model) basis

      boolean computeSegFeaturesSymbol(Sdb& sdb_features, Sdb& sdb_symbols);

- methods to open databases

      boolean openAudioDatabase();

      boolean openTransDatabase();

- methods to close databases

      boolean closeAudioDatabase();

      boolean closeTransDatabase();

- method to retrieve feature file from audio database

      boolean retrieveFtrFile(const Strinf& identifier, Filename& ftr_file);

- method to retrieve alignments from transcription database

      boolean retrieveAlign(const Strinf& identifier, const String& symbol, VectorLong& start_frame, VectorLong& end_frames);

- method to read features from feature file

      boolean readFeatures(const Filename& ftr_file, Vector& features);

- method to write features from feature file

      boolean writeFeatures(const Filename& ftr_file, const Vector& features);

- method to write min-max values to min-max file

      boolean writeMinMax();

- method to generate segmental features

      boolean generateSegFeature(const Vector& features, const VectorLong& start_frames, const VectorLong& end_frames, Vector& seg_features);

- method to normalize the features

      boolean normalizeFeatures(const Vector& features, Vector& min_max, Vector& norm_features);

examples:

- none. this class is not to be used directly.

notes:

- none