diff --git a/CMakeLists.txt b/CMakeLists.txt index 3762db115..b4d27503a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,12 +56,20 @@ else() endif() option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +if(BUILD_SHARED_LIBS) + add_definitions(-DSPHINX_DLL) +endif() option(FIXED_POINT "Build using fixed-point math" OFF) if(NOT DEFAULT_RADIX) set(DEFAULT_RADIX 12) endif() cmake_print_variables(FIXED_POINT DEFAULT_RADIX) +# Maybe not a great idea, but it does work on both Windows and Linux +set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + configure_file(config.h.in config.h) configure_file(sphinx_config.h.in include/sphinxbase/sphinx_config.h) add_definitions(-DHAVE_CONFIG_H) diff --git a/include/sphinxbase/ckd_alloc.h b/include/sphinxbase/ckd_alloc.h index 221ed6cae..5bb60d499 100644 --- a/include/sphinxbase/ckd_alloc.h +++ b/include/sphinxbase/ckd_alloc.h @@ -124,6 +124,7 @@ extern "C" { * allocation fails rather than exiting or calling longjmp(). * @return Pointer to a previously set jmp_buf, if any. */ +SPHINXBASE_EXPORT jmp_buf *ckd_set_jump(jmp_buf *env, int abort); /** diff --git a/include/sphinxbase/pio.h b/include/sphinxbase/pio.h index fe094a60b..b9a658ae9 100644 --- a/include/sphinxbase/pio.h +++ b/include/sphinxbase/pio.h @@ -239,11 +239,13 @@ typedef struct bit_encode_s bit_encode_t; /** * Attach bitstream encoder to a file. */ +SPHINXBASE_EXPORT bit_encode_t *bit_encode_attach(FILE *outfh); /** * Retain pointer to a bit encoder. */ +SPHINXBASE_EXPORT bit_encode_t *bit_encode_retain(bit_encode_t *be); /** @@ -251,21 +253,25 @@ bit_encode_t *bit_encode_retain(bit_encode_t *be); * * Note that this does NOT flush any leftover bits. */ +SPHINXBASE_EXPORT int bit_encode_free(bit_encode_t *be); /** * Write bits to encoder. */ +SPHINXBASE_EXPORT int bit_encode_write(bit_encode_t *be, unsigned char const *bits, int nbits); /** * Write lowest-order bits of codeword to encoder. */ +SPHINXBASE_EXPORT int bit_encode_write_cw(bit_encode_t *be, uint32 codeword, int nbits); /** * Flush any unwritten bits, zero-padding if necessary. */ +SPHINXBASE_EXPORT int bit_encode_flush(bit_encode_t *be); /** diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a74f943d1..98b707683 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,11 @@ target_link_libraries(pocketsphinx PUBLIC Threads::Threads) # Shared library version != package version, unfortunately set_target_properties(pocketsphinx PROPERTIES VERSION 4.0.0 - SOVERSION 4) + SOVERSION 4 + ) +# No idea why this can't just go in the above list but oh well +set_property(TARGET pocketsphinx PROPERTY + COMPILE_DEFINITIONS POCKETSPHINX_EXPORTS;SPHINXBASE_EXPORTS +) install(TARGETS pocketsphinx LIBRARY) diff --git a/src/acmod.h b/src/acmod.h index 6ec345b56..b534278ab 100644 --- a/src/acmod.h +++ b/src/acmod.h @@ -57,6 +57,7 @@ /* Local headers. */ #include +#include #include "bin_mdef.h" #include "tmat.h" #include "hmm.h" @@ -225,6 +226,7 @@ typedef struct acmod_s acmod_t; * model, this function will fail. This pointer is retained. * @return a newly initialized acmod_t, or NULL on failure. */ +POCKETSPHINX_EXPORT acmod_t *acmod_init(cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb); /** @@ -234,6 +236,7 @@ acmod_t *acmod_init(cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb); * @param fe acoustic feature extraction module to verify. * @return TRUE if compatible, FALSE otherwise */ +POCKETSPHINX_EXPORT int acmod_fe_mismatch(acmod_t *acmod, fe_t *fe); /** @@ -243,6 +246,7 @@ int acmod_fe_mismatch(acmod_t *acmod, fe_t *fe); * @param fcb dynamic feature computation module to verify. * @return TRUE if compatible, FALSE otherwise */ +POCKETSPHINX_EXPORT int acmod_feat_mismatch(acmod_t *acmod, feat_t *fcb); /** @@ -255,6 +259,7 @@ int acmod_feat_mismatch(acmod_t *acmod, feat_t *fcb); * @return The updated transform object for this decoder, or * NULL on failure. */ +POCKETSPHINX_EXPORT ps_mllr_t *acmod_update_mllr(acmod_t *acmod, ps_mllr_t *mllr); /** @@ -264,6 +269,7 @@ ps_mllr_t *acmod_update_mllr(acmod_t *acmod, ps_mllr_t *mllr); * @param logfh Filehandle to log to. * @return 0 for success, <0 on error. */ +POCKETSPHINX_EXPORT int acmod_set_senfh(acmod_t *acmod, FILE *senfh); /** @@ -273,6 +279,7 @@ int acmod_set_senfh(acmod_t *acmod, FILE *senfh); * @param logfh Filehandle to log to. * @return 0 for success, <0 on error. */ +POCKETSPHINX_EXPORT int acmod_set_mfcfh(acmod_t *acmod, FILE *logfh); /** @@ -282,21 +289,25 @@ int acmod_set_mfcfh(acmod_t *acmod, FILE *logfh); * @param logfh Filehandle to log to. * @return 0 for success, <0 on error. */ +POCKETSPHINX_EXPORT int acmod_set_rawfh(acmod_t *acmod, FILE *logfh); /** * Finalize an acoustic model. */ +POCKETSPHINX_EXPORT void acmod_free(acmod_t *acmod); /** * Mark the start of an utterance. */ +POCKETSPHINX_EXPORT int acmod_start_utt(acmod_t *acmod); /** * Mark the end of an utterance. */ +POCKETSPHINX_EXPORT int acmod_end_utt(acmod_t *acmod); /** @@ -311,6 +322,7 @@ int acmod_end_utt(acmod_t *acmod); * @return 0 for success, <0 for failure (if the utterance can't be * rewound due to no feature or score data available) */ +POCKETSPHINX_EXPORT int acmod_rewind(acmod_t *acmod); /** @@ -322,6 +334,7 @@ int acmod_rewind(acmod_t *acmod); * * @return New frame index. */ +POCKETSPHINX_EXPORT int acmod_advance(acmod_t *acmod); /** @@ -332,6 +345,7 @@ int acmod_advance(acmod_t *acmod); * model. * @return previous allocation policy. */ +POCKETSPHINX_EXPORT int acmod_set_grow(acmod_t *acmod, int grow_feat); /** @@ -352,6 +366,7 @@ int acmod_set_grow(acmod_t *acmod, int grow_feat); * utterance and should be processed as such. * @return Number of frames of data processed. */ +POCKETSPHINX_EXPORT int acmod_process_raw(acmod_t *acmod, int16 const **inout_raw, size_t *inout_n_samps, @@ -368,6 +383,7 @@ int acmod_process_raw(acmod_t *acmod, * utterance and should be processed as such. * @return Number of frames of data processed. */ +POCKETSPHINX_EXPORT int acmod_process_cep(acmod_t *acmod, mfcc_t ***inout_cep, int *inout_n_frames, @@ -386,6 +402,7 @@ int acmod_process_cep(acmod_t *acmod, * @param feat Pointer to one frame of dynamic features. * @return Number of frames processed (either 0 or 1). */ +POCKETSPHINX_EXPORT int acmod_process_feat(acmod_t *acmod, mfcc_t **feat); @@ -395,6 +412,7 @@ int acmod_process_feat(acmod_t *acmod, * @param insenfh File handle of dump file * @return 0 for success, <0 for failure */ +POCKETSPHINX_EXPORT int acmod_set_insenfh(acmod_t *acmod, FILE *insenfh); /** @@ -402,6 +420,7 @@ int acmod_set_insenfh(acmod_t *acmod, FILE *insenfh); * * @return Number of frames read or <0 on error. */ +POCKETSPHINX_EXPORT int acmod_read_scores(acmod_t *acmod); /** @@ -413,6 +432,7 @@ int acmod_read_scores(acmod_t *acmod); * set of features. * @return Feature array, or NULL if requested frame is not available. */ +POCKETSPHINX_EXPORT mfcc_t **acmod_get_frame(acmod_t *acmod, int *inout_frame_idx); /** @@ -428,17 +448,20 @@ mfcc_t **acmod_get_frame(acmod_t *acmod, int *inout_frame_idx); * data pointed to persists only until the next call to * acmod_score() or acmod_advance(). */ +POCKETSPHINX_EXPORT int16 const *acmod_score(acmod_t *acmod, int *inout_frame_idx); /** * Write senone dump file header. */ +POCKETSPHINX_EXPORT int acmod_write_senfh_header(acmod_t *acmod, FILE *logfh); /** * Write a frame of senone scores to a dump file. */ +POCKETSPHINX_EXPORT int acmod_write_scores(acmod_t *acmod, int n_active, uint8 const *active, int16 const *senscr, FILE *senfh); @@ -446,6 +469,7 @@ int acmod_write_scores(acmod_t *acmod, int n_active, uint8 const *active, /** * Get best score and senone index for current frame. */ +POCKETSPHINX_EXPORT int acmod_best_score(acmod_t *acmod, int *out_best_senid); /** @@ -466,26 +490,31 @@ void acmod_activate_hmm(acmod_t *acmod, hmm_t *hmm); /** * Build active list. */ +POCKETSPHINX_EXPORT int32 acmod_flags2list(acmod_t *acmod); /** * Get the offset of the utterance start of the current stream, helpful for stream-wide timing. */ +POCKETSPHINX_EXPORT int32 acmod_stream_offset(acmod_t *acmod); /** * Reset the current stream */ +POCKETSPHINX_EXPORT void acmod_start_stream(acmod_t *acmod); /** * Sets the limit of the raw audio data to store */ +POCKETSPHINX_EXPORT void acmod_set_rawdata_size(acmod_t *acmod, int32 size); /** * Retrieves the raw data collected during utterance decoding */ +POCKETSPHINX_EXPORT void acmod_get_rawdata(acmod_t *acmod, int16 **buffer, int32 *size); #ifdef __cplusplus diff --git a/src/bin_mdef.h b/src/bin_mdef.h index 7ebdf287e..97db1454e 100644 --- a/src/bin_mdef.h +++ b/src/bin_mdef.h @@ -188,16 +188,19 @@ int bin_mdef_write_text(bin_mdef_t *m, const char *filename); /** * Retain a pointer to a bin_mdef_t. */ +POCKETSPHINX_EXPORT bin_mdef_t *bin_mdef_retain(bin_mdef_t *m); /** * Release a pointer to a binary mdef. */ +POCKETSPHINX_EXPORT int bin_mdef_free(bin_mdef_t *m); /** * Context-independent phone lookup. * @return phone id for ciphone. */ +POCKETSPHINX_EXPORT int bin_mdef_ciphone_id(bin_mdef_t *m, /**< In: Model structure being queried */ const char *ciphone); /**< In: ciphone for which id wanted */ @@ -205,14 +208,17 @@ int bin_mdef_ciphone_id(bin_mdef_t *m, /**< In: Model structure being que * Case-insensitive context-independent phone lookup. * @return phone id for ciphone. */ +POCKETSPHINX_EXPORT int bin_mdef_ciphone_id_nocase(bin_mdef_t *m, /**< In: Model structure being queried */ const char *ciphone); /**< In: ciphone for which id wanted */ /* Return value: READ-ONLY ciphone string name for the given ciphone id */ +POCKETSPHINX_EXPORT const char *bin_mdef_ciphone_str(bin_mdef_t *m, /**< In: Model structure being queried */ int32 ci); /**< In: ciphone id for which name wanted */ /* Return value: phone id for the given constituents if found, else -1 */ +POCKETSPHINX_EXPORT int bin_mdef_phone_id(bin_mdef_t *m, /**< In: Model structure being queried */ int32 b, /**< In: base ciphone id */ int32 l, /**< In: left context ciphone id */ @@ -220,6 +226,7 @@ int bin_mdef_phone_id(bin_mdef_t *m, /**< In: Model structure being queried */ int32 pos); /**< In: Word position */ /* Look up a phone id, backing off to other word positions. */ +POCKETSPHINX_EXPORT int bin_mdef_phone_id_nearest(bin_mdef_t * m, int32 b, int32 l, int32 r, int32 pos); @@ -228,6 +235,7 @@ int bin_mdef_phone_id_nearest(bin_mdef_t * m, int32 b, * * @return 0 if successful, -1 if error. */ +POCKETSPHINX_EXPORT int bin_mdef_phone_str(bin_mdef_t *m, /**< In: Model structure being queried */ int pid, /**< In: phone id being queried */ char *buf); /**< Out: On return, buf has the string */ diff --git a/src/dict.h b/src/dict.h index 5a98c46e6..804d465be 100644 --- a/src/dict.h +++ b/src/dict.h @@ -103,6 +103,7 @@ typedef struct dict_s { * * Return ptr to dict_t if successful, NULL otherwise. */ +POCKETSPHINX_EXPORT dict_t *dict_init(cmd_ln_t *config, /**< Configuration (-dict, -fdict, -dictcase) or NULL */ bin_mdef_t *mdef /**< For looking up CI phone IDs (or NULL) */ ); @@ -110,6 +111,7 @@ dict_t *dict_init(cmd_ln_t *config, /**< Configuration (-dict, -fdict, -dictcase /** * Write dictionary to a file. */ +POCKETSPHINX_EXPORT int dict_write(dict_t *dict, char const *filename, char const *format); /** Return word id for given word string if present. Otherwise return BAD_S3WID */ @@ -120,6 +122,7 @@ s3wid_t dict_wordid(dict_t *d, const char *word); * Return 1 if w is a filler word, 0 if not. A filler word is one that was read in from the * filler dictionary; however, sentence START and FINISH words are not filler words. */ +POCKETSPHINX_EXPORT int dict_filler_word(dict_t *d, /**< The dictionary structure */ s3wid_t w /**< The word ID */ ); @@ -136,6 +139,7 @@ int dict_real_word(dict_t *d, /**< The dictionary structure */ * Add a word with the given ciphone pronunciation list to the dictionary. * Return value: Result word id if successful, BAD_S3WID otherwise */ +POCKETSPHINX_EXPORT s3wid_t dict_add_word(dict_t *d, /**< The dictionary structure. */ char const *word, /**< The word. */ s3cipid_t const *p, /**< The pronunciation. */ @@ -145,6 +149,7 @@ s3wid_t dict_add_word(dict_t *d, /**< The dictionary structure. */ /** * Return value: CI phone string for the given word, phone position. */ +POCKETSPHINX_EXPORT const char *dict_ciphone_str(dict_t *d, /**< In: Dictionary to look up */ s3wid_t wid, /**< In: Component word being looked up */ int32 pos /**< In: Pronunciation phone position */ @@ -190,19 +195,23 @@ const char *dict_ciphone_str(dict_t *d, /**< In: Dictionary to look up */ * Return value: If string was modified, the character position at which the original string * was truncated; otherwise -1. */ +POCKETSPHINX_EXPORT int32 dict_word2basestr(char *word); /** * Retain a pointer to an dict_t. */ +POCKETSPHINX_EXPORT dict_t *dict_retain(dict_t *d); /** * Release a pointer to a dictionary. */ +POCKETSPHINX_EXPORT int dict_free(dict_t *d); /** Report a dictionary structure */ +POCKETSPHINX_EXPORT void dict_report(dict_t *d /**< A dictionary structure */ ); diff --git a/src/dict2pid.h b/src/dict2pid.h index 56566a4bc..c08d3e555 100644 --- a/src/dict2pid.h +++ b/src/dict2pid.h @@ -46,6 +46,7 @@ #include /* Local headers. */ +#include #include "s3types.h" #include "bin_mdef.h" #include "dict.h" @@ -122,6 +123,7 @@ typedef struct dict2pid_s { /** * Build the dict2pid structure for the given model/dictionary */ +POCKETSPHINX_EXPORT dict2pid_t *dict2pid_build(bin_mdef_t *mdef, /**< A model definition*/ dict_t *dict /**< An initialized dictionary */ ); @@ -129,11 +131,13 @@ dict2pid_t *dict2pid_build(bin_mdef_t *mdef, /**< A model definition*/ /** * Retain a pointer to dict2pid */ +POCKETSPHINX_EXPORT dict2pid_t *dict2pid_retain(dict2pid_t *d2p); /** * Free the memory dict2pid structure */ +POCKETSPHINX_EXPORT int dict2pid_free(dict2pid_t *d2p /**< In: the d2p */ ); @@ -147,6 +151,7 @@ s3ssid_t dict2pid_internal(dict2pid_t *d2p, /** * Add a word to the dict2pid structure (after adding it to dict). */ +POCKETSPHINX_EXPORT int dict2pid_add_word(dict2pid_t *d2p, int32 wid); diff --git a/src/ngram_search.h b/src/ngram_search.h index 7436b88b8..a575fa32f 100644 --- a/src/ngram_search.h +++ b/src/ngram_search.h @@ -50,6 +50,7 @@ #include /* Local headers. */ +#include #include "pocketsphinx_internal.h" #include "hmm.h" @@ -407,6 +408,7 @@ void ngram_search_free_all_rc(ngram_search_t *ngs, int32 w); * * @return the backpointer index of the best word exit. */ +POCKETSPHINX_EXPORT int ngram_search_find_exit(ngram_search_t *ngs, int frame_idx, int32 *out_best_score); /** @@ -414,6 +416,7 @@ int ngram_search_find_exit(ngram_search_t *ngs, int frame_idx, int32 *out_best_s * * @return a read-only string with the best hypothesis. */ +POCKETSPHINX_EXPORT char const *ngram_search_bp_hyp(ngram_search_t *ngs, int bpidx); /** @@ -424,6 +427,7 @@ void ngram_compute_seg_scores(ngram_search_t *ngs, float32 lwf); /** * Construct a word lattice from the current hypothesis. */ +POCKETSPHINX_EXPORT ps_lattice_t *ngram_search_lattice(ps_search_t *search); /** diff --git a/src/ngram_search_fwdtree.h b/src/ngram_search_fwdtree.h index 68b5c5408..5d28b4782 100644 --- a/src/ngram_search_fwdtree.h +++ b/src/ngram_search_fwdtree.h @@ -45,6 +45,7 @@ /* SphinxBase headers. */ /* Local headers. */ +#include #include "ngram_search.h" #ifdef __cplusplus @@ -72,6 +73,7 @@ int ngram_fwdtree_reinit(ngram_search_t *ngs); /** * Start fwdtree decoding for an utterance. */ +POCKETSPHINX_EXPORT void ngram_fwdtree_start(ngram_search_t *ngs); /** @@ -79,11 +81,13 @@ void ngram_fwdtree_start(ngram_search_t *ngs); * * @return Number of frames searched (either 0 or 1). */ +POCKETSPHINX_EXPORT int ngram_fwdtree_search(ngram_search_t *ngs, int frame_idx); /** * Finish fwdtree decoding for an utterance. */ +POCKETSPHINX_EXPORT void ngram_fwdtree_finish(ngram_search_t *ngs); #ifdef __cplusplus diff --git a/src/ps_alignment.h b/src/ps_alignment.h index b855da31d..8b471efa7 100644 --- a/src/ps_alignment.h +++ b/src/ps_alignment.h @@ -46,6 +46,7 @@ /* SphinxBase headers. */ #include +#include /* Local headers. */ #include "dict2pid.h" @@ -103,67 +104,80 @@ typedef struct ps_alignment_iter_s ps_alignment_iter_t; /** * Create a new, empty alignment. */ +POCKETSPHINX_EXPORT ps_alignment_t *ps_alignment_init(dict2pid_t *d2p); /** * Retain an alighment */ +POCKETSPHINX_EXPORT ps_alignment_t *ps_alignment_retain(ps_alignment_t *al); /** * Release an alignment */ +POCKETSPHINX_EXPORT int ps_alignment_free(ps_alignment_t *al); /** * Append a word. */ +POCKETSPHINX_EXPORT int ps_alignment_add_word(ps_alignment_t *al, int32 wid, int duration); /** * Populate lower layers using available word information. */ +POCKETSPHINX_EXPORT int ps_alignment_populate(ps_alignment_t *al); /** * Populate lower layers using context-independent phones. */ +POCKETSPHINX_EXPORT int ps_alignment_populate_ci(ps_alignment_t *al); /** * Propagate timing information up from state sequence. */ +POCKETSPHINX_EXPORT int ps_alignment_propagate(ps_alignment_t *al); /** * Number of words. */ +POCKETSPHINX_EXPORT int ps_alignment_n_words(ps_alignment_t *al); /** * Number of phones. */ +POCKETSPHINX_EXPORT int ps_alignment_n_phones(ps_alignment_t *al); /** * Number of states. */ +POCKETSPHINX_EXPORT int ps_alignment_n_states(ps_alignment_t *al); /** * Iterate over the alignment starting at the first word. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_words(ps_alignment_t *al); /** * Iterate over the alignment starting at the first phone. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_phones(ps_alignment_t *al); /** * Iterate over the alignment starting at the first state. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_states(ps_alignment_t *al); /** @@ -171,11 +185,13 @@ ps_alignment_iter_t *ps_alignment_states(ps_alignment_t *al); * * The iterator retains ownership of this so don't try to free it. */ +POCKETSPHINX_EXPORT ps_alignment_entry_t *ps_alignment_iter_get(ps_alignment_iter_t *itor); /** * Move alignment iterator to given index. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_iter_goto(ps_alignment_iter_t *itor, int pos); /** @@ -184,6 +200,7 @@ ps_alignment_iter_t *ps_alignment_iter_goto(ps_alignment_iter_t *itor, int pos); * If the end of the alignment is reached, this will free the iterator * and return NULL. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_iter_next(ps_alignment_iter_t *itor); /** @@ -192,6 +209,7 @@ ps_alignment_iter_t *ps_alignment_iter_next(ps_alignment_iter_t *itor); * If the start of the alignment is reached, this will free the iterator * and return NULL. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_iter_prev(ps_alignment_iter_t *itor); /** @@ -199,17 +217,20 @@ ps_alignment_iter_t *ps_alignment_iter_prev(ps_alignment_iter_t *itor); * * If there is no parent node, NULL is returned. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_iter_up(ps_alignment_iter_t *itor); /** * Get a new iterator starting at the first child of the current node. * * If there is no child node, NULL is returned. */ +POCKETSPHINX_EXPORT ps_alignment_iter_t *ps_alignment_iter_down(ps_alignment_iter_t *itor); /** * Release an iterator before completing all iterations. */ +POCKETSPHINX_EXPORT int ps_alignment_iter_free(ps_alignment_iter_t *itor); #ifdef __cplusplus diff --git a/src/ps_lattice_internal.h b/src/ps_lattice_internal.h index a9de60139..39b4fbfc2 100644 --- a/src/ps_lattice_internal.h +++ b/src/ps_lattice_internal.h @@ -43,6 +43,7 @@ #define __PS_LATTICE_INTERNAL_H__ /* Local headers. */ +#include #include "pocketsphinx_internal.h" #ifdef __cplusplus @@ -217,6 +218,7 @@ void ps_lattice_penalize_fillers(ps_lattice_t *dag, int32 silpen, int32 fillpen) /** * Remove nodes marked as unreachable. */ +POCKETSPHINX_EXPORT void ps_lattice_delete_unreachable(ps_lattice_t *dag); /** @@ -243,6 +245,7 @@ latlink_list_t *latlink_list_new(ps_lattice_t *dag, ps_latlink_t *link, /** * Get hypothesis string after bestpath search. */ +POCKETSPHINX_EXPORT char const *ps_lattice_hyp(ps_lattice_t *dag, ps_latlink_t *link); /** diff --git a/src/state_align_search.h b/src/state_align_search.h index 5e65ec485..95bd19bd2 100644 --- a/src/state_align_search.h +++ b/src/state_align_search.h @@ -46,6 +46,7 @@ #include /* Local headers. */ +#include #include "pocketsphinx_internal.h" #include "ps_alignment.h" #include "hmm.h" @@ -85,6 +86,7 @@ struct state_align_search_s { }; typedef struct state_align_search_s state_align_search_t; +POCKETSPHINX_EXPORT ps_search_t *state_align_search_init(const char *name, cmd_ln_t *config, acmod_t *acmod, diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0086d1320..b7bdc5a03 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,4 @@ +find_program(BASH_PROGRAM bash) configure_file(testfuncs.sh.in testfuncs.sh @ONLY) add_subdirectory(regression) diff --git a/test/regression/CMakeLists.txt b/test/regression/CMakeLists.txt index d571ddd69..99e43ae8b 100644 --- a/test/regression/CMakeLists.txt +++ b/test/regression/CMakeLists.txt @@ -7,7 +7,7 @@ set(TESTS ) foreach(TEST ${TESTS}) if(${TEST} MATCHES "\.(test|sh)$") - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) else() add_test(NAME ${TEST} COMMAND ${TEST}) endif() diff --git a/test/regression/testfuncs.sh.in b/test/regression/testfuncs.sh.in deleted file mode 100644 index 8cabcbe4d..000000000 --- a/test/regression/testfuncs.sh.in +++ /dev/null @@ -1,60 +0,0 @@ -# Utility functions and parameters for regression tests - -# Predefined directories you may need -# Stupid broken RedHat autoconf doesn't do @abs_top_srcdir@ -builddir="@top_builddir@" -sourcedir="@top_srcdir@" -tests=$sourcedir/test - -# Automatically report failures on exit -failures="" -trap "report_failures" 0 - -run_program() { - program="$1" - shift - $builddir/libtool --mode=execute "$builddir/src/$program" $@ -} - -debug_program() { - program="$1" - shift - $builddir/libtool --mode=execute gdb --args "$builddir/src/$program" $@ -} - -memcheck_program() { - program="$1" - shift - $builddir/libtool --mode=execute valgrind --leak-check=full "$builddir/src/$program" $@ -} - -pass() { - title="$1" - echo "$title PASSED" -} - -fail() { - title="$1" - echo "$title FAILED" - failures="$failures,$title" -} - -compare_table() { - title="$1" - shift - if perl "$tests/compare_table.pl" $@ | grep SUCCESS >/dev/null 2>&1; then - pass "$title" - else - fail "$title" - fi -} - -report_failures() { - if test x"$failures" = x; then - echo "All sub-tests passed" - exit 0 - else - echo "Sub-tests failed:$failures" | sed -e 's/,/ /g' - exit 1 - fi -} diff --git a/test/testfuncs.sh.in b/test/testfuncs.sh.in index b342a603c..09e689010 100644 --- a/test/testfuncs.sh.in +++ b/test/testfuncs.sh.in @@ -7,7 +7,7 @@ sourcedir="@CMAKE_SOURCE_DIR@" tests=$sourcedir/test data=$sourcedir/test/data model=$sourcedir/model -programs="$builddir/programs" +programs=$builddir # Automatically report failures on exit failures="" diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index f71381f17..0a2efe002 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -38,7 +38,7 @@ foreach(TEST_EXECUTABLE ${TESTS}) ${TEST_EXECUTABLE} PRIVATE ${CMAKE_BINARY_DIR} ${TEST_EXECUTABLE} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) - add_test(${TEST_EXECUTABLE} ${TEST_EXECUTABLE}) + add_test(NAME ${TEST_EXECUTABLE} COMMAND ${TEST_EXECUTABLE}) endforeach() add_subdirectory(test_alloc) diff --git a/test/unit/test_alloc/CMakeLists.txt b/test/unit/test_alloc/CMakeLists.txt index 216a1632a..98dfc66b4 100644 --- a/test/unit/test_alloc/CMakeLists.txt +++ b/test/unit/test_alloc/CMakeLists.txt @@ -20,5 +20,5 @@ add_test(NAME test_listelem_alloc COMMAND test_listelem_alloc) add_test(NAME test_ckd_alloc_catch COMMAND test_ckd_alloc_catch) add_test(NAME test_ckd_alloc_fail COMMAND test_ckd_alloc_fail) set_property(TEST test_ckd_alloc_fail PROPERTY WILL_FAIL TRUE) -add_test(NAME test_ckd_alloc_abort COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/test_ckd_alloc_abort.sh) +add_test(NAME test_ckd_alloc_abort COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/test_ckd_alloc_abort.sh) set_property(TEST test_ckd_alloc_abort PROPERTY ENVIRONMENT CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}) diff --git a/test/unit/test_case/CMakeLists.txt b/test/unit/test_case/CMakeLists.txt index 9b55f5860..0d54efaf8 100644 --- a/test/unit/test_case/CMakeLists.txt +++ b/test/unit/test_case/CMakeLists.txt @@ -23,5 +23,6 @@ set(TESTS _ucase3.test ) foreach(TEST ${TESTS}) - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) endforeach() diff --git a/test/unit/test_cmdln/CMakeLists.txt b/test/unit/test_cmdln/CMakeLists.txt index d7c7f8291..06bd145a0 100644 --- a/test/unit/test_cmdln/CMakeLists.txt +++ b/test/unit/test_cmdln/CMakeLists.txt @@ -21,6 +21,7 @@ set(TESTS _test_parse_multiple.test ) foreach(TEST ${TESTS}) - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_property(TEST ${TEST} PROPERTY ENVIRONMENT CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}) endforeach() diff --git a/test/unit/test_cmdln/cmdln_parse.c b/test/unit/test_cmdln/cmdln_parse.c index 6c897996e..ac586ae32 100644 --- a/test/unit/test_cmdln/cmdln_parse.c +++ b/test/unit/test_cmdln/cmdln_parse.c @@ -18,7 +18,9 @@ const arg_t defs[] = { int main(int argc, char *argv[]) { - cmd_ln_t *config = cmd_ln_parse_r(NULL, defs, argc, argv, FALSE); + cmd_ln_t *config = cmd_ln_parse_r(NULL, defs, argc, argv, TRUE); + if (config == NULL) + return 1; printf("%ld %s %d %f\n", cmd_ln_int_r(config, "-a"), cmd_ln_str_r(config, "-b") ? cmd_ln_str_r(config, "-b") : "(null)", diff --git a/test/unit/test_feat/CMakeLists.txt b/test/unit/test_feat/CMakeLists.txt index ef27b99d0..63805b440 100644 --- a/test/unit/test_feat/CMakeLists.txt +++ b/test/unit/test_feat/CMakeLists.txt @@ -22,7 +22,7 @@ set(TESTS ) foreach(TEST ${TESTS}) if(${TEST} MATCHES "\.(test|sh)$") - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) else() add_test(NAME ${TEST} COMMAND ${TEST}) endif() diff --git a/test/unit/test_hash/CMakeLists.txt b/test/unit/test_hash/CMakeLists.txt index 008f84dff..47db663b0 100644 --- a/test/unit/test_hash/CMakeLists.txt +++ b/test/unit/test_hash/CMakeLists.txt @@ -23,7 +23,7 @@ set(TESTS ) foreach(TEST ${TESTS}) if(${TEST} MATCHES "\.(test|sh)$") - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) else() add_test(NAME ${TEST} COMMAND ${TEST}) endif() diff --git a/test/unit/test_matrix/CMakeLists.txt b/test/unit/test_matrix/CMakeLists.txt index 7e61b7b3d..9db0ae8ef 100644 --- a/test/unit/test_matrix/CMakeLists.txt +++ b/test/unit/test_matrix/CMakeLists.txt @@ -20,7 +20,8 @@ set(TESTS ) foreach(TEST ${TESTS}) if(${TEST} MATCHES "\.(test|sh)$") - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) else() add_test(NAME ${TEST} COMMAND ${TEST}) endif() diff --git a/test/unit/test_string/CMakeLists.txt b/test/unit/test_string/CMakeLists.txt index e650b8523..55ebd7eed 100644 --- a/test/unit/test_string/CMakeLists.txt +++ b/test/unit/test_string/CMakeLists.txt @@ -24,7 +24,8 @@ set(TESTS ) foreach(TEST ${TESTS}) if(${TEST} MATCHES "\.(test|sh)$") - add_test(NAME ${TEST} COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}) + add_test(NAME ${TEST} COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) else() add_test(NAME ${TEST} COMMAND ${TEST}) endif()