-
Notifications
You must be signed in to change notification settings - Fork 1
/
kaldi-to-htk.cpp
52 lines (38 loc) · 1.21 KB
/
kaldi-to-htk.cpp
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
#include <string>
#include <iostream>
#include <array.h>
#include <archive_io.h>
#include <cmdparser.h>
void saveFeatureArchiveAsHtk(const string& featArk);
using namespace std;
int main(int argc, char* argv[]) {
CmdParser cmdParser(argc, argv);
cmdParser
.addGroup("Generic options:")
.add("-q", "filename of the query list")
.add("-f", "folder containing all the feature archive");
if(!cmdParser.isOptionLegal())
cmdParser.showUsageAndExit();
string ql_fn = cmdParser.find("-q");
string archive = cmdParser.find("-f");
Array<string> queries(ql_fn);
for (size_t i=0; i<queries.size(); ++i) {
string fn = archive + "/" + queries[i] + ".76.ark";
cout << fn << endl;
saveFeatureArchiveAsHtk(fn);
}
return 0;
}
void saveFeatureArchiveAsHtk(const string& featArk) {
FILE* fptr = fopen(featArk.c_str(), "r");
VulcanUtterance vUtterance;
while (vUtterance.LoadKaldi(fptr)) {
const FeatureSeq& fs = vUtterance._feature;
string docId = vUtterance.fid();
docId = replace_all(docId, "mfc", "gp");
docId = replace_all(docId, "SI_word", "SI_word_gp");
docId = replace_all(docId, "OOV_g2p", "OOV_g2p_gp");
// cout << docId << endl;
save(fs, docId);
}
}