forked from rampa069/PhnRec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstkinterface.h
118 lines (88 loc) · 3.17 KB
/
stkinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**************************************************************************
* copyright : (C) 2004-2006 by Petr Schwarz & Pavel Matejka *
* UPGM,FIT,VUT,Brno *
* email : {schwarzp,matejkap}@fit.vutbr.cz *
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#ifndef STK_StkInterface_h
#define STK_StkInterface_h
#undef USE_BLAS
#undef min
#undef max
//namespace std
//{
// #define min(a,b) (a < b ? a : b)
//}
#include <fileio.h>
#include <common.h>
#include <Models.h>
#include <Viterbi.h>
#include <labels.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include "decoder.h"
// #undef min
using namespace STK;
class StkInterface : public Decoder
{
protected:
MyHSearchData phoneHash;
MyHSearchData dictHash;
bool NetworkLoaded;
bool HMMSetLoaded;
long lastTime;
long timePruning;
float beamPruning;
float wPenalty;
float lmScale;
bool improveKwdEstim;
FILE* fp_lab;
// stk structures
ModelSet hset;
Network net;
// kws
struct _LRTrace
{
Node *mpWordEnd;
float lastLR;
float candidateLR;
long_long candidateStartTime;
long_long candidateEndTime;
long_long prevCandidateEndTime;
bool dumped;
} *lrt;
typedef struct _LRTrace LRTrace;
Token* filler_end;
int nKeywords;
float kwsScorePruning;
void PutKWSCandidateToLabels(LRTrace *lrt);
public:
StkInterface();
~StkInterface();
int ReadHMMSet(char *mmFileName);
int LoadNetwork(char *file_name);
// Batch processing
// int ProcessFile(char *features, char *label_file, float *score);
// Per frame processing
int Init(char *label_file = 0);
void ProcessFrame(float *frame);
float Done();
// Configuration
void SetTimePruning(long v) {timePruning = v;};
void SetBeamPruning(float v) {beamPruning = v; net.mPruningThresh = v;};
void SetKwsScorePruning(float v) {kwsScorePruning = v;};
void SetWPenalty(float v) {wPenalty = v; net.mWPenalty = (double)v;};
void SetLmScale(float v) {lmScale = v; net.mLmScale = (double)v;};
void SetImproveKwdEstim(bool v) {improveKwdEstim = v;};
void SetLMScale(float v) {lmScale = v;};
void ErrorMessage(char *msg);
};
#endif // #define STK_StkInterface_h