Skip to content

Commit f0f9e7a

Browse files
author
kkm
committed
Work around an apparent namespace-in-template scoping bug in MSVC on Windows.
Parent track: 16c1ba0 P
1 parent c8bf5c6 commit f0f9e7a

24 files changed

+220
-104
lines changed

src/bin/align-text.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ bool IsNotToken(const std::string &token) {
2626
return ! kaldi::IsToken(token);
2727
}
2828

29-
int main(int argc, char *argv[]) {
30-
using namespace kaldi;
31-
typedef kaldi::int32 int32;
29+
namespace kaldi {
3230

31+
int main(int argc, char *argv[]) {
3332
try {
3433
const char *usage =
3534
"Computes alignment between two sentences with the same key in the\n"
@@ -133,3 +132,10 @@ int main(int argc, char *argv[]) {
133132
return -1;
134133
}
135134
}
135+
136+
} //namespace kaldi
137+
138+
139+
int main(int argc, char *argv[]) {
140+
return kaldi::main(argc, argv);
141+
}

src/bin/extract-ctx.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "tree/build-tree-questions.h"
3030
#include "fst/fstlib.h"
3131

32-
using namespace kaldi;
32+
namespace kaldi {
3333

3434
using std::vector;
3535

@@ -212,4 +212,9 @@ int main(int argc, char *argv[]) {
212212
}
213213
}
214214

215+
} //namespace kaldi
215216

217+
218+
int main(int argc, char *argv[]) {
219+
return kaldi::main(argc, argv);
220+
}

src/bin/phones-to-prons.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "fst/fstlib.h"
2727
#include "fstext/fstext-lib.h"
2828

29+
namespace kaldi {
30+
2931
// Create FST that accepts the phone sequence, with any number
3032
// of word-start and word-end symbol in between each phone.
3133
void CreatePhonesAltFst(const std::vector<int32> &phones,
@@ -60,10 +62,8 @@ void CreatePhonesAltFst(const std::vector<int32> &phones,
6062
}
6163

6264
int main(int argc, char *argv[]) {
63-
using namespace kaldi;
6465
using fst::VectorFst;
6566
using fst::StdArc;
66-
typedef kaldi::int32 int32;
6767
try {
6868
const char *usage =
6969
"Convert pairs of (phone-level, word-level) transcriptions to\n"
@@ -220,4 +220,9 @@ int main(int argc, char *argv[]) {
220220
}
221221
}
222222

223+
} //namespace kaldi
224+
223225

226+
int main(int argc, char *argv[]) {
227+
return kaldi::main(argc, argv);
228+
}

src/bin/post-to-phone-post.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
#include "hmm/transition-model.h"
2424
#include "hmm/posterior.h"
2525

26+
namespace kaldi {
27+
2628
int main(int argc, char *argv[]) {
2729
try {
28-
using namespace kaldi;
29-
typedef kaldi::int32 int32;
30-
3130
const char *usage =
3231
"Convert posteriors to phone-level posteriors\n"
3332
"See also: post-to-pdf-post, post-to-weights, get-post-on-ali\n"
@@ -75,3 +74,9 @@ int main(int argc, char *argv[]) {
7574
}
7675
}
7776

77+
} //namespace kaldi
78+
79+
80+
int main(int argc, char *argv[]) {
81+
return kaldi::main(argc, argv);
82+
}

src/gmmbin/gmm-decode-nbest.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "lat/kaldi-lattice.h" // for CompactLatticeArc
3131
#include "fstext/lattice-utils.h" // for ConvertLattice
3232

33-
using namespace kaldi;
33+
namespace kaldi {
3434

3535
fst::Fst<fst::StdArc> *ReadNetwork(std::string filename) {
3636
// read decoding network FST
@@ -67,8 +67,6 @@ fst::Fst<fst::StdArc> *ReadNetwork(std::string filename) {
6767

6868
int main(int argc, char *argv[]) {
6969
try {
70-
typedef kaldi::int32 int32;
71-
7270
const char *usage =
7371
"Decode features using GMM-based model, producing N-best lattice output.\n"
7472
"Note: this program was mainly intended to validate the lattice generation\n"
@@ -245,4 +243,9 @@ int main(int argc, char *argv[]) {
245243
}
246244
}
247245

246+
} //namespace kaldi
247+
248248

249+
int main(int argc, char *argv[]) {
250+
return kaldi::main(argc, argv);
251+
}

src/kwsbin/generate-proxy-keywords.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// See the Apache 2 License for the specific language governing permissions and
1818
// limitations under the License.
1919

20-
2120
#include "base/kaldi-common.h"
2221
#include "util/common-utils.h"
2322
#include "fstext/fstext-utils.h"
@@ -53,15 +52,16 @@ bool PrintProxyFstPath(const VectorFst<StdArc> &proxy,
5352
}
5453
}
5554

55+
using namespace fst;
56+
using kaldi::int32;
57+
using kaldi::uint64;
58+
using kaldi::BasicVectorHolder;
59+
using kaldi::ParseOptions;
60+
using kaldi::SequentialInt32VectorReader;
61+
using kaldi::TableWriter;
62+
5663
int main(int argc, char *argv[]) {
5764
try {
58-
using namespace kaldi;
59-
using namespace fst;
60-
typedef kaldi::int32 int32;
61-
typedef kaldi::uint64 uint64;
62-
typedef StdArc::StateId StateId;
63-
typedef StdArc::Weight Weight;
64-
6565
const char *usage =
6666
"Convert the keywords into in-vocabulary words using the given phone\n"
6767
"level edit distance fst (E.fst). The large lexicon (L2.fst) and\n"

src/kwsbin/kws-index-union.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
#include "lat/kaldi-kws.h"
2525
#include "lat/kws-functions.h"
2626

27+
using namespace fst;
28+
using kaldi::int32;
29+
using kaldi::uint64;
30+
using kaldi::KwsLexicographicArc;
31+
using kaldi::KwsLexicographicFst;
32+
using kaldi::ParseOptions;
33+
using kaldi::SequentialTableReader;
34+
using kaldi::TableWriter;
35+
2736
int main(int argc, char *argv[]) {
2837
try {
29-
using namespace kaldi;
30-
using namespace fst;
31-
typedef kaldi::int32 int32;
32-
typedef kaldi::uint64 uint64;
33-
3438
const char *usage =
3539
"Take a union of the indexed lattices. The input index is in the T*T*T semiring and\n"
3640
"the output index is also in the T*T*T semiring. At the end of this program, encoded\n"

src/kwsbin/kws-search.cc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,25 @@ class VectorFstToKwsLexicographicFstMapper {
7070

7171
}
7272

73+
using namespace fst;
74+
using kaldi::int32;
75+
using kaldi::uint64;
76+
using kaldi::BasicVectorHolder;
77+
using kaldi::DecodeLabelUid;
78+
using kaldi::EncodeLabel;
79+
using kaldi::KwsLexicographicArc;
80+
using kaldi::KwsLexicographicFst;
81+
using kaldi::ParseOptions;
82+
using kaldi::RandomAccessTableReader;
83+
using kaldi::SequentialTableReader;
84+
using kaldi::TableWriter;
85+
using kaldi::VectorFstToKwsLexicographicFstMapper;
86+
7387
int main(int argc, char *argv[]) {
88+
typedef KwsLexicographicArc Arc;
89+
typedef Arc::Weight Weight;
90+
typedef Arc::StateId StateId;
7491
try {
75-
using namespace kaldi;
76-
using namespace fst;
77-
typedef kaldi::int32 int32;
78-
typedef kaldi::uint32 uint32;
79-
typedef kaldi::uint64 uint64;
80-
typedef KwsLexicographicArc Arc;
81-
typedef Arc::Weight Weight;
82-
typedef Arc::StateId StateId;
83-
8492
const char *usage =
8593
"Search the keywords over the index. This program can be executed parallely, either\n"
8694
"on the index side or the keywords side; we use a script to combine the final search\n"

src/kwsbin/lattice-to-kws-index.cc

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,32 @@
2828
#include "lat/kws-functions.h"
2929
#include "fstext/epsilon-property.h"
3030

31+
using fst::VectorFst;
32+
using kaldi::int32;
33+
using kaldi::uint64;
34+
using kaldi::BaseFloat;
35+
using kaldi::ClusterLattice;
36+
using kaldi::CompactLattice;
37+
using kaldi::CompactLatticeStateTimes;
38+
using kaldi::CompactLatticeStateTimes;
39+
using kaldi::CreateFactorTransducer;
40+
using kaldi::DoFactorDisambiguation;
41+
using kaldi::DoFactorMerging;
42+
using kaldi::KwsLexicographicArc;
43+
using kaldi::KwsLexicographicFst;
44+
using kaldi::KwsProductFst;
45+
using kaldi::MaybeDoSanityCheck;
46+
using kaldi::OptimizeFactorTransducer;
47+
using kaldi::ParseOptions;
48+
using kaldi::RandomAccessInt32Reader;
49+
using kaldi::RandomAccessTableReader;
50+
using kaldi::RemoveLongSilences;
51+
using kaldi::SequentialCompactLatticeReader;
52+
using kaldi::SequentialTableReader;
53+
using kaldi::TableWriter;
54+
3155
int main(int argc, char *argv[]) {
3256
try {
33-
using namespace kaldi;
34-
using fst::VectorFst;
35-
typedef kaldi::int32 int32;
36-
typedef kaldi::uint64 uint64;
37-
3857
const char *usage =
3958
"Create an inverted index of the given lattices. The output index is in the T*T*T\n"
4059
"semiring. For details for the semiring, please refer to Dogan Can and Muran Saraclar's"

src/latbin/lattice-add-trans-probs.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
#include "hmm/transition-model.h"
2727
#include "hmm/hmm-utils.h"
2828

29+
namespace kaldi {
30+
2931
int main(int argc, char *argv[]) {
3032
try {
31-
using namespace kaldi;
32-
typedef kaldi::int32 int32;
33-
typedef kaldi::int64 int64;
3433
using fst::SymbolTable;
3534
using fst::VectorFst;
3635
using fst::StdArc;
@@ -90,3 +89,10 @@ int main(int argc, char *argv[]) {
9089
return -1;
9190
}
9291
}
92+
93+
} //namespace kaldi
94+
95+
96+
int main(int argc, char *argv[]) {
97+
return kaldi::main(argc, argv);
98+
}

0 commit comments

Comments
 (0)