📄 segmentconcat.h
字号:
// file: $isip/class/mmedia/SegmentConcat/SegmentConcat.h// version: $Id: SegmentConcat.h,v 1.4 2003/05/07 15:54:04 parihar Exp $//// make sure definitions are only made once//#ifndef ISIP_SEGMENT_CONCAT#define ISIP_SEGMENT_CONCAT// isip include files//#ifndef ISIP_VECTOR_FLOAT#include <VectorFloat.h>#endif#ifndef ISIP_SDB#include <Sdb.h>#endif#ifndef ISIP_FEATURE_FILE#include <FeatureFile.h>#endif#ifndef ISIP_TRANSCRIPTION_DATABASE#include <TranscriptionDatabase.h>#endif#ifndef ISIP_AUDIO_DATABASE#include <AudioDatabase.h>#endif#ifndef ISIP_MEMORY_MANAGER#include <MemoryManager.h>#endif// SegmentConcat: a class that manuiplates the feature// vectors. currently, two algorithms are supported:// MIN_MAX - compute the min-max for each dimension of the feature-vectors.// SEG_CONCAT - manuplate the feature vectors given the segmental// information. The two implementations supported for SEG_CONCAT are NONE and// NORMALIZE.//class SegmentConcat { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { MIN_MAX = 0, SEG_CONCAT, 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; static const NameMap IMPL_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; //---------------------------------------- // // default values and arguments // //---------------------------------------- static const long DEF_DIMENSION = 39; static const double MAX_LOG_DURATION = 3.912; //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = 50800; //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // dimension of the inout features // Long dim_d; // static memory manager // static MemoryManager mgr_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; //--------------------------------------------------------------------------- // // required public methods // //---------------------------------------------------------------------------public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static boolean diagnose(Integral::DEBUG debug_level); // method: setDebug // static boolean setDebug(Integral::DEBUG arg) { debug_level_d = arg; return true; } // other debug methods // boolean debug(const unichar* msg) const; // method: destructor // ~SegmentConcat() {} // method: default constructor // SegmentConcat(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION) { algorithm_d = algorithm; implementation_d = implementation; } // method: copy constructor // SegmentConcat(const SegmentConcat& arg) { assign(arg); } // assign methods // boolean assign(const SegmentConcat& arg); // method: operator= // SegmentConcat& operator= (const SegmentConcat& arg) { assign(arg); return *this; } // 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; // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static boolean setGrowSize(long grow_size) { return mgr_d.setGrow(grow_size); } // other memory management methods // boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setAlgorithm // boolean setAlgorithm(ALGORITHM algorithm) { algorithm_d = algorithm; return true; } // method: setImplementation // boolean setImplementation(IMPLEMENTATION implementation) { implementation_d = implementation; return true; } // method: setDimension // boolean setDimension(long dim) { dim_d = dim; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getAlgorithm // ALGORITHM getAlgorithm() const { return algorithm_d; } // method: getImplementation // IMPLEMENTATION getImplementation() const { return implementation_d; } // method: getDimension // long getDimension() const { return dim_d; } //--------------------------------------------------------------------------- // // class-specific public methods: // computational methods // //--------------------------------------------------------------------------- // method to compute the minimun and maximum value in each dimension // boolean compute(Sdb& sdb, Filename& audiodb_file, FeatureFile::FILE_TYPE f_type, FeatureFile::FILE_FORMAT f_format, Vector<VectorFloat>& min_max); // method to compute the concatenated segmental features // boolean compute(Sdb& sdb, Filename& audiodb_file, Filename& transdb_file, FeatureFile::FILE_TYPE in_f_type, FeatureFile::FILE_FORMAT in_f_format, String& level, String& ratio, boolean dur, boolean norm, Filename& min_max_file, FeatureFile::FILE_TYPE o_f_type, FeatureFile::FILE_FORMAT o_f_format, String& suffix); //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // method to generate segmental features // boolean generateSegFeature(Vector<VectorFloat>& features, VectorLong& start_frames, VectorLong& end_frames, VectorLong& seg_ratio, boolean duration, Vector<VectorFloat>& seg_features); // method to normalize features // boolean normalizeFeature(Vector<VectorFloat>& features, Vector<VectorFloat>& min_max, Vector<VectorFloat>& norm_features);};// end of include file// #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -