Skip to content

Commit 18c8e3e

Browse files
committed
Make code more GCC-tolerant and add Qt project for Linux compiling
1 parent 513a04c commit 18c8e3e

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
TEMPLATE = app
2+
CONFIG += console c++14
3+
CONFIG -= app_bundle
4+
CONFIG -= qt
5+
6+
HEADERS += \
7+
TensorflowTTSCppInference/EnglishPhoneticProcessor.h \
8+
TensorflowTTSCppInference/FastSpeech2.h \
9+
TensorflowTTSCppInference/MultiBandMelGAN.h \
10+
TensorflowTTSCppInference/TextTokenizer.h \
11+
TensorflowTTSCppInference/Voice.h \
12+
TensorflowTTSCppInference/VoxCommon.hpp \
13+
TensorflowTTSCppInference/ext/AudioFile.hpp \
14+
TensorflowTTSCppInference/ext/CppFlow/include/Model.h \
15+
TensorflowTTSCppInference/ext/CppFlow/include/Tensor.h \
16+
TensorflowTTSCppInference/ext/ZCharScanner.h
17+
18+
SOURCES += \
19+
TensorflowTTSCppInference/EnglishPhoneticProcessor.cpp \
20+
TensorflowTTSCppInference/FastSpeech2.cpp \
21+
TensorflowTTSCppInference/MultiBandMelGAN.cpp \
22+
TensorflowTTSCppInference/TensorflowTTSCppInference.cpp \
23+
TensorflowTTSCppInference/TextTokenizer.cpp \
24+
TensorflowTTSCppInference/Voice.cpp \
25+
TensorflowTTSCppInference/VoxCommon.cpp \
26+
TensorflowTTSCppInference/ext/CppFlow/src/Model.cpp \
27+
TensorflowTTSCppInference/ext/CppFlow/src/Tensor.cpp \
28+
TensorflowTTSCppInference/ext/ZCharScanner.cpp
29+
30+
INCLUDEPATH += $$PWD/deps/include
31+
LIBS += -L$$PWD/deps/lib -lfst -lfstfar -lfstngram -ltensorflow -lphonetisaurus
32+
33+
# GCC shits itself on memcp in AudioFile.hpp (l-1186) unless we add this
34+
QMAKE_CXXFLAGS += -fpermissive
35+
36+
# Stop ld from whining about LoadClusters
37+
QMAKE_CXXFLAGS += -Wl,-b,svr4,-z,multidefs

examples/cppwin/TensorflowTTSCppInference/FastSpeech2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ bool FastSpeech2::Initialize(const std::string & SavedModelFolder)
2828

2929
TFTensor<float> FastSpeech2::DoInference(const std::vector<int32_t>& InputIDs, int32_t SpeakerID, float Speed, float Energy, float F0)
3030
{
31-
if (!FastSpeech)
32-
throw std::exception("Tried to do inference on unloaded or invalid model!");
31+
VX_IF_EXCEPT(!FastSpeech,"Tried to do inference on unloaded or invalid model!")
32+
3333

3434
// Convenience reference so that we don't have to constantly derefer pointers.
3535
Model& Mdl = *FastSpeech;

examples/cppwin/TensorflowTTSCppInference/MultiBandMelGAN.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "MultiBandMelGAN.h"
2-
#define IF_EXCEPT(cond,ex) if (cond){throw std::exception(ex);}
32

43

54

@@ -19,7 +18,7 @@ bool MultiBandMelGAN::Initialize(const std::string & VocoderPath)
1918

2019
TFTensor<float> MultiBandMelGAN::DoInference(const TFTensor<float>& InMel)
2120
{
22-
IF_EXCEPT(!MelGAN, "Tried to infer MB-MelGAN on uninitialized model!!!!");
21+
VX_IF_EXCEPT(!MelGAN, "Tried to infer MB-MelGAN on uninitialized model!!!!");
2322

2423
// Convenience reference so that we don't have to constantly derefer pointers.
2524
Model& Mdl = *MelGAN;

examples/cppwin/TensorflowTTSCppInference/TensorflowTTSCppInference.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include "Voice.h"
44
#define LOGF(txt) std::cout << txt << "\n"
55

6-
7-
86
int main()
97
{
108
bool Running = true;

examples/cppwin/TensorflowTTSCppInference/TextTokenizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <algorithm>
44
#include <cassert>
55
#include <cctype>
6+
#include <stdexcept>
67
const std::vector<std::string> first14 = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen" };
78
const std::vector<std::string> prefixes = { "twen", "thir", "for", "fif", "six", "seven", "eigh", "nine" };
89

examples/cppwin/TensorflowTTSCppInference/VoxCommon.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include <vector>
77
#include "ext/AudioFile.hpp"
88
#include "ext/CppFlow/include/Tensor.h"
9+
#include <stdexcept>
910

1011
#define IF_RETURN(cond,ret) if (cond){return ret;}
12+
#define VX_IF_EXCEPT(cond,ex) if (cond){throw std::invalid_argument(ex);}
1113

1214

1315
template<typename T>
@@ -53,4 +55,4 @@ namespace VoxUtil {
5355
}
5456

5557
void ExportWAV(const std::string& Filename, const std::vector<float>& Data, unsigned SampleRate);
56-
}
58+
}

examples/cppwin/TensorflowTTSCppInference/ext/CppFlow/src/Tensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <utility>
88
// Disable "loss of data" warnings
99
#pragma warning( disable : 4267)
10-
10+
#include <memory>
1111

1212
Tensor::Tensor(const Model& model, const std::string& operation) {
1313

examples/cppwin/TensorflowTTSCppInference/ext/ZCharScanner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "ZCharScanner.h"
2+
#include <stdexcept>
23
using namespace std;
34

45
int ZStringDelimiter::key_search(const GString& s, const GString& key)

0 commit comments

Comments
 (0)