PocketSphinx  5prealpha
kws_search.h
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 2013 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  *
19  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
20  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
23  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * ====================================================================
32  *
33  */
34 
35 /*
36  * kws_search.h -- Search structures for keyphrase spotting.
37  */
38 
39 #ifndef __KWS_SEARCH_H__
40 #define __KWS_SEARCH_H__
41 
42 /* SphinxBase headers. */
43 #include <sphinxbase/glist.h>
44 #include <sphinxbase/cmd_ln.h>
45 
46 /* Local headers. */
47 #include "pocketsphinx_internal.h"
48 #include "kws_detections.h"
49 #include "hmm.h"
50 
54 typedef struct kws_seg_s {
56  gnode_t *detection;
58 } kws_seg_t;
59 
60 typedef struct kws_keyphrase_s {
61  char* word;
62  int32 threshold;
63  hmm_t* hmms;
64  int32 n_hmms;
66 
70 typedef struct kws_search_s {
71  ps_search_t base;
72 
75  glist_t keyphrases;
80  int32 beam;
81 
82  int32 plp;
83  int32 bestscore;
84  int32 def_threshold;
85  int32 delay;
87  int32 n_pl;
90  ptmr_t perf;
91  int32 n_tot_frame;
92 
93 } kws_search_t;
94 
99 ps_search_t *kws_search_init(const char *name,
100  const char *keyphrase,
101  const char *keyfile,
102  cmd_ln_t * config,
103  acmod_t * acmod,
104  dict_t * dict, dict2pid_t * d2p);
105 
109 void kws_search_free(ps_search_t * search);
110 
114 int kws_search_reinit(ps_search_t * kwss, dict_t * dict, dict2pid_t * d2p);
115 
120 int kws_search_start(ps_search_t * search);
121 
125 int kws_search_step(ps_search_t * search, int frame_idx);
126 
130 int kws_search_finish(ps_search_t * search);
131 
135 char const *kws_search_hyp(ps_search_t * search, int32 * out_score);
136 
140 char* kws_search_get_keyphrases(ps_search_t * search);
141 
142 #endif /* __KWS_SEARCH_H__ */
Internal implementation of PocketSphinx decoder.
frame_idx_t last_frame
Last frame to raise the detection.
Definition: kws_search.h:57
Base structure for search module.
glist_t keyphrases
Keyphrases to spot.
Definition: kws_search.h:75
An individual HMM among the HMM search space.
gnode_t * detection
Keyphrase detection correspondent to segment.
Definition: kws_search.h:56
int32 plp
Phone loop probability.
Definition: kws_search.h:82
int32 def_threshold
default threshold for p(hyp)/p(altern) ratio
Definition: kws_search.h:84
Segmentation &quot;iterator&quot; for KWS history.
Definition: kws_search.h:54
int32 bestscore
For beam pruning.
Definition: kws_search.h:83
Implementation of HMM base structure.
hmm_t * pl_hmms
Phone loop hmms - hmms of CI phones.
Definition: kws_search.h:88
hmm_context_t * hmmctx
HMM context.
Definition: kws_search.h:73
int32 delay
Delay to wait for best detection score.
Definition: kws_search.h:85
Shared information between a set of HMMs.
ps_seg_t base
Base structure.
Definition: kws_search.h:55
a structure for a dictionary.
Definition: dict.h:76
frame_idx_t frame
Frame index.
Definition: kws_search.h:78
int32 n_pl
Number of CI phones.
Definition: kws_search.h:87
int32 frame_idx_t
Type for frame index values.
Definition: hmm.h:64
Implementation of KWS search structure.
Definition: kws_search.h:70
kws_detections_t * detections
Keyword spotting history.
Definition: kws_search.h:77
ptmr_t perf
Performance counter.
Definition: kws_search.h:90
Base structure for hypothesis segmentation iterator.
Acoustic model structure.
Definition: acmod.h:148
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:84