Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TensorSpeech
GitHub Repository: TensorSpeech/TensorFlowTTS
Path: blob/master/examples/cppwin/TensorflowTTSCppInference/Voice.h
1559 views
1
#pragma once
2
3
#include "FastSpeech2.h"
4
#include "MultiBandMelGAN.h"
5
#include "EnglishPhoneticProcessor.h"
6
7
8
class Voice
9
{
10
private:
11
FastSpeech2 MelPredictor;
12
MultiBandMelGAN Vocoder;
13
EnglishPhoneticProcessor Processor;
14
VoiceInfo VoxInfo;
15
16
17
18
std::vector<std::string> Phonemes;
19
std::vector<int32_t> PhonemeIDs;
20
21
22
23
std::vector<int32_t> PhonemesToID(const std::string& InTxt);
24
25
std::vector<std::string> Speakers;
26
std::vector<std::string> Emotions;
27
28
void ReadPhonemes(const std::string& PhonemePath);
29
30
void ReadSpeakers(const std::string& SpeakerPath);
31
32
void ReadEmotions(const std::string& EmotionPath);
33
34
35
void ReadModelInfo(const std::string& ModelInfoPath);
36
37
std::vector<std::string> GetLinedFile(const std::string& Path);
38
39
40
std::string ModelInfo;
41
42
public:
43
/* Voice constructor, arguments obligatory.
44
-> VoxPath: Path of folder where models are contained.
45
-- Must be a folder without an ending slash with UNIX slashes, can be relative or absolute (eg: MyVoices/Karen)
46
-- The folder must contain the following elements:
47
--- melgen: Folder generated where a FastSpeech2 model was saved as SavedModel, with .pb, variables, etc
48
--- vocoder: Folder where a Multi-Band MelGAN model was saved as SavedModel.
49
--- info.json: Model information
50
--- phonemes.txt: Tab delimited file containing PHONEME \t ID, for inputting to the FS2 model.
51
52
--- If multispeaker, a lined .txt file called speakers.txt
53
--- If multi-emotion, a lined .txt file called emotions.txt
54
55
*/
56
Voice(const std::string& VoxPath, const std::string& inName,Phonemizer* InPhn);
57
58
void AddPhonemizer(Phonemizer* InPhn);
59
60
61
std::vector<float> Vocalize(const std::string& Prompt, float Speed = 1.f, int32_t SpeakerID = 0, float Energy = 1.f, float F0 = 1.f,int32_t EmotionID = -1);
62
63
std::string Name;
64
inline const VoiceInfo& GetInfo(){return VoxInfo;}
65
66
inline const std::vector<std::string>& GetSpeakers(){return Speakers;}
67
inline const std::vector<std::string>& GetEmotions(){return Emotions;}
68
69
inline const std::string& GetModelInfo(){return ModelInfo;}
70
71
~Voice();
72
};
73
74
75