Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Sphinx/include/pocketsphinx/cmdln_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@
{ "-logfn", \
ARG_STRING, \
NULL, \
"File to write log messages in" \
}, \
"File to write log messages in" }, \
{ "-debug", \
ARG_INT32, \
NULL, \
"Verbosity level for debugging messages" \
}, \
"Verbosity level for debugging messages" }, \
{ "-mfclogdir", \
ARG_STRING, \
NULL, \
Expand All @@ -78,7 +76,7 @@
ARG_STRING, \
NULL, \
"Directory to log raw audio files to" }, \
{ "-senlogdir", \
{ "-senlogdir", \
ARG_STRING, \
NULL, \
"Directory to log senone score files to" \
Expand Down Expand Up @@ -196,6 +194,10 @@
ARG_FLOAT64, \
"1e-1", \
"Phone loop probability for keyword spotting" }, \
{ "-kws_delay", \
ARG_INT32, \
"10", \
"Delay to wait for best detection score" }, \
{ "-kws_threshold", \
ARG_FLOAT64, \
"1", \
Expand Down
38 changes: 16 additions & 22 deletions Sphinx/include/pocketsphinx/pocketsphinx.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
#ifndef __POCKETSPHINX_H__
#define __POCKETSPHINX_H__

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

/* System headers we need. */
#include <stdio.h>
Expand All @@ -60,6 +54,13 @@ extern "C" {
#include <ps_lattice.h>
#include <ps_mllr.h>

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

/**
* PocketSphinx speech recognizer object.
*/
Expand Down Expand Up @@ -88,8 +89,8 @@ ps_default_search_args(cmd_ln_t *);
* Initialize the decoder from a configuration object.
*
* @note The decoder retains ownership of the pointer
* <code>config</code>, so you must not attempt to free it manually.
* If you wish to reuse it elsewhere, call cmd_ln_retain() on it.
* <code>config</code>, so if you are not going to use it
* elsewere, you can free it.
*
* @param config a command-line structure, as created by
* cmd_ln_parse_r() or cmd_ln_parse_file_r().
Expand Down Expand Up @@ -454,12 +455,11 @@ ps_lattice_t *ps_get_lattice(ps_decoder_t *ps);
* Get an iterator over the word segmentation for the best hypothesis.
*
* @param ps Decoder.
* @param out_best_score Output: path score corresponding to hypothesis.
* @return Iterator over the best hypothesis at this point in
* decoding. NULL if no hypothesis is available.
*/
POCKETSPHINX_EXPORT
ps_seg_t *ps_seg_iter(ps_decoder_t *ps, int32 *out_best_score);
ps_seg_t *ps_seg_iter(ps_decoder_t *ps);

/**
* Get the next segment in a word segmentation.
Expand Down Expand Up @@ -527,22 +527,15 @@ POCKETSPHINX_EXPORT
void ps_seg_free(ps_seg_t *seg);

/**
* Get an iterator over the best hypotheses, optionally within a
* selected region of the utterance. Iterator is empty now, it must
* be advanced with ps_nbest_next first. The function may also
* Get an iterator over the best hypotheses. The function may also
* return a NULL which means that there is no hypothesis available for this
* utterance.
*
* @param ps Decoder.
* @param sf Start frame for N-best search (0 for whole utterance)
* @param ef End frame for N-best search (-1 for whole utterance)
* @param ctx1 First word of trigram context (NULL for whole utterance)
* @param ctx2 First word of trigram context (NULL for whole utterance)
* @return Iterator over N-best hypotheses or NULL if no hypothesis is available
*/
POCKETSPHINX_EXPORT
ps_nbest_t *ps_nbest(ps_decoder_t *ps, int sf, int ef,
char const *ctx1, char const *ctx2);
ps_nbest_t *ps_nbest(ps_decoder_t *ps);

/**
* Move an N-best list iterator forward.
Expand Down Expand Up @@ -572,7 +565,7 @@ char const *ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score);
* @return Iterator over the next best hypothesis.
*/
POCKETSPHINX_EXPORT
ps_seg_t *ps_nbest_seg(ps_nbest_t *nbest, int32 *out_score);
ps_seg_t *ps_nbest_seg(ps_nbest_t *nbest);

/**
* Finish N-best search early, releasing resources.
Expand Down Expand Up @@ -641,8 +634,9 @@ void ps_get_rawdata(ps_decoder_t *ps, int16 **buffer, int32 *size);
/**
* @mainpage PocketSphinx API Documentation
* @author David Huggins-Daines <dhuggins@cs.cmu.edu>
* @version 0.6
* @date March, 2010
* @author Alpha Cephei Inc.
* @version 5prealpha
* @date July, 2015
*
* @section intro_sec Introduction
*
Expand Down
8 changes: 4 additions & 4 deletions Sphinx/include/pocketsphinx/pocketsphinx_export.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef __POCKETSPHINX_EXPORT_H__
#define __POCKETSPHINX_EXPORT_H__

/* Win32/WinCE DLL gunk */
#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(_WIN32_WP) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__WINSCW__) && !defined(__SYMBIAN32__)
#ifdef POCKETSPHINX_EXPORTS /* Visual Studio */
/* Win32 DLL gunk */
#if defined(_WIN32) && defined(SPHINX_DLL)
#if defined(POCKETSPHINX_EXPORTS) /* DLL itself */
#define POCKETSPHINX_EXPORT __declspec(dllexport)
#else
#define POCKETSPHINX_EXPORT __declspec(dllimport)
#endif
#else /* !_WIN32 */
#else /* No DLL things*/
#define POCKETSPHINX_EXPORT
#endif

Expand Down
11 changes: 11 additions & 0 deletions Sphinx/include/pocketsphinx/ps_lattice.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
/* PocketSphinx headers. */
#include <pocketsphinx_export.h>

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

/**
* Word graph structure used in bestpath/nbest search.
*/
Expand Down Expand Up @@ -442,4 +449,8 @@ int32 ps_lattice_ngram_expand(ps_lattice_t *dag, ngram_model_t *lm);
POCKETSPHINX_EXPORT
int ps_lattice_n_frames(ps_lattice_t *dag);

#ifdef __cplusplus
}
#endif

#endif /* __PS_LATTICE_H__ */
11 changes: 11 additions & 0 deletions Sphinx/include/pocketsphinx/ps_mllr.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
/* PocketSphinx headers. */
#include <pocketsphinx_export.h>

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

/**
* Feature space linear transform object.
*/
Expand All @@ -72,4 +79,8 @@ ps_mllr_t *ps_mllr_retain(ps_mllr_t *mllr);
POCKETSPHINX_EXPORT
int ps_mllr_free(ps_mllr_t *mllr);

#ifdef __cplusplus
}
#endif

#endif /* __PS_MLLR_H__ */
14 changes: 9 additions & 5 deletions Sphinx/include/pocketsphinx/ps_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
*
* Each search has a name and can be referenced by a name, names are
* application-specific. The function ps_set_search allows to activate
* the search previously added by a name.
* the search previously added by a name. Only single search can be
* activated at time.
*
* To add the search one needs to point to the grammar/language model
* describing the search. The location of the grammar is specific to the
Expand All @@ -67,12 +68,15 @@
#ifndef __PS_SEARCH_H__
#define __PS_SEARCH_H__

#include <sphinxbase/fsg_model.h>
#include <sphinxbase/ngram_model.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <sphinxbase/fsg_model.h>
#include <sphinxbase/ngram_model.h>
#if 0
}
#endif

/**
* PocketSphinx search iterator.
Expand All @@ -86,7 +90,7 @@ typedef struct ps_search_iter_s ps_search_iter_t;
* Activates search with the provided name. The search must be added before
* using either ps_set_fsg(), ps_set_lm() or ps_set_kws().
*
* @return 0 on success, 1 on failure
* @return 0 on success, -1 on failure
*/
POCKETSPHINX_EXPORT
int ps_set_search(ps_decoder_t *ps, const char *name);
Expand Down
149 changes: 149 additions & 0 deletions Sphinx/include/sphinxbase/bitarr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 2015 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/

#ifndef _LIBUTIL_BITARR_H_
#define _LIBUTIL_BITARR_H_

#include <assert.h>
#include <string.h>

#include <sphinxbase/prim_type.h>
/* Win32/WinCE DLL gunk */
#include <sphinxbase/sphinxbase_export.h>

/**
* @file bitarr.h
* @brief An implementation bit array - memory efficient storage for digit int and float data.
*
* Implementation of basic operations of read/write digits consuming as little space as possible.
*/

#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Fool Emacs. */
}
#endif

/**
* Structure that specifies bits required to efficiently store certain data
*/
typedef struct bitarr_mask_s {
uint8 bits;
uint32 mask;
}bitarr_mask_t;

/**
* Structure that stores address of certain value in bit array
*/
typedef struct bitarr_address_s {
void *base;
uint32 offset;
}bitarr_address_t;

/**
* Read uint64 value from bit array.
* Assumes mask == (1 << length) - 1 where length <= 57
* @param address to read from
* @param length number of bits for value
* @param mask of read value
* @return uint64 value that was read
*/
SPHINXBASE_EXPORT
uint64
bitarr_read_int57(bitarr_address_t address, uint8 length, uint64 mask);

/**
* Write specified value into bit array.
* Assumes value < (1 << length) and length <= 57.
* Assumes the memory is zero initially.
* @param address to write to
* @param length amount of active bytes in value to write
* @param value integer to write
*/
SPHINXBASE_EXPORT
void
bitarr_write_int57(bitarr_address_t address, uint8 length, uint64 value);

/**
* Read uint32 value from bit array.
* Assumes mask == (1 << length) - 1 where length <= 25
* @param address to read from
* @param length number of bits for value
* @param mask of read value
* @return uint32 value that was read
*/
SPHINXBASE_EXPORT
uint32
bitarr_read_int25(bitarr_address_t address, uint8 length, uint32 mask);

/**
* Write specified value into bit array.
* Assumes value < (1 << length) and length <= 25.
* Assumes the memory is zero initially.
* @param address in bit array ti write to
* @param length amount of active bytes in value to write
* @param value integer to write
*/
SPHINXBASE_EXPORT
void
bitarr_write_int25(bitarr_address_t address, uint8 length, uint32 value);

/**
* Fills mask for certain int range according to provided max value
* @param bit_mask mask that is filled
* @param max_value bigest integer that is going to be stored using this mask
*/
SPHINXBASE_EXPORT
void
bitarr_mask_from_max(bitarr_mask_t *bit_mask, uint32 max_value);

/**
* Computes amount of bits required ti store integers upto value provided.
* @param max_value bigest integer that going to be stored using this amount of bits
* @return amount of bits required to store integers from range with maximum provided
*/
SPHINXBASE_EXPORT
uint8
bitarr_required_bits(uint32 max_value);

#ifdef __cplusplus
}
#endif

#endif /* _LIBUTIL_BITARR_H_ */
Loading