kws_search.h
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 2013 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 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.
*
* ====================================================================
*
*/
/*
* kws_search.h -- Search structures for keyphrase spotting.
*/
#ifndef __KWS_SEARCH_H__
#define __KWS_SEARCH_H__
/* SphinxBase headers. */
#include <sphinxbase/glist.h>
#include <sphinxbase/cmd_ln.h>
/* Local headers. */
#include "pocketsphinx_internal.h"
#include "kws_detections.h"
#include "hmm.h"
typedef struct kws_seg_s {
ps_seg_t base;
gnode_t *detection;
frame_idx_t last_frame;
} kws_seg_t;
typedef struct kws_keyphrase_s {
char* word;
int32 threshold;
hmm_t* hmms;
int32 n_hmms;
} kws_keyphrase_t;
typedef struct kws_search_s {
ps_search_t base;
hmm_context_t *hmmctx;
glist_t keyphrases;
kws_detections_t *detections;
frame_idx_t frame;
int32 beam;
int32 plp;
int32 bestscore;
int32 def_threshold;
int32 delay;
int32 n_pl;
hmm_t *pl_hmms;
ptmr_t perf;
int32 n_tot_frame;
} kws_search_t;
ps_search_t *kws_search_init(const char *name,
const char *keyphrase,
const char *keyfile,
cmd_ln_t * config,
acmod_t * acmod,
dict_t * dict, dict2pid_t * d2p);
void kws_search_free(ps_search_t * search);
int kws_search_reinit(ps_search_t * kwss, dict_t * dict, dict2pid_t * d2p);
int kws_search_start(ps_search_t * search);
int kws_search_step(ps_search_t * search, int frame_idx);
int kws_search_finish(ps_search_t * search);
char const *kws_search_hyp(ps_search_t * search, int32 * out_score);
char* kws_search_get_keyphrases(ps_search_t * search);
#endif /* __KWS_SEARCH_H__ */
hmm.h
Implementation of HMM base structure.
frame_idx_t
int32 frame_idx_t
Type for frame index values.
Definition hmm.h:64
pocketsphinx_internal.h
Internal implementation of PocketSphinx decoder.
acmod_s
Acoustic model structure.
Definition acmod.h:148
dict2pid_t
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition dict2pid.h:84
dict_t
a structure for a dictionary.
Definition dict.h:76
hmm_context_t
Shared information between a set of HMMs.
hmm_t
An individual HMM among the HMM search space.
kws_detections_s
Definition kws_detections.h:57
kws_keyphrase_s
Definition kws_search.h:60
kws_search_s
Implementation of KWS search structure.
Definition kws_search.h:70
kws_search_s::hmmctx
hmm_context_t * hmmctx
HMM context.
Definition kws_search.h:73
kws_search_s::bestscore
int32 bestscore
For beam pruning.
Definition kws_search.h:83
kws_search_s::perf
ptmr_t perf
Performance counter.
Definition kws_search.h:90
kws_search_s::plp
int32 plp
Phone loop probability.
Definition kws_search.h:82
kws_search_s::keyphrases
glist_t keyphrases
Keyphrases to spot.
Definition kws_search.h:75
kws_search_s::frame
frame_idx_t frame
Frame index.
Definition kws_search.h:78
kws_search_s::pl_hmms
hmm_t * pl_hmms
Phone loop hmms - hmms of CI phones.
Definition kws_search.h:88
kws_search_s::n_pl
int32 n_pl
Number of CI phones.
Definition kws_search.h:87
kws_search_s::detections
kws_detections_t * detections
Keyword spotting history.
Definition kws_search.h:77
kws_search_s::delay
int32 delay
Delay to wait for best detection score.
Definition kws_search.h:85
kws_search_s::def_threshold
int32 def_threshold
default threshold for p(hyp)/p(altern) ratio
Definition kws_search.h:84
kws_seg_s
Segmentation "iterator" for KWS history.
Definition kws_search.h:54
kws_seg_s::detection
gnode_t * detection
Keyphrase detection correspondent to segment.
Definition kws_search.h:56
kws_seg_s::last_frame
frame_idx_t last_frame
Last frame to raise the detection.
Definition kws_search.h:57
kws_seg_s::base
ps_seg_t base
Base structure.
Definition kws_search.h:55
ps_search_s
Base structure for search module.
Definition pocketsphinx_internal.h:98
ps_seg_s
Base structure for hypothesis segmentation iterator.
Definition pocketsphinx_internal.h:178