Path: blob/master/examples/cppwin/TensorflowTTSCppInference/Voice.h
1559 views
#pragma once12#include "FastSpeech2.h"3#include "MultiBandMelGAN.h"4#include "EnglishPhoneticProcessor.h"567class Voice8{9private:10FastSpeech2 MelPredictor;11MultiBandMelGAN Vocoder;12EnglishPhoneticProcessor Processor;13VoiceInfo VoxInfo;14151617std::vector<std::string> Phonemes;18std::vector<int32_t> PhonemeIDs;19202122std::vector<int32_t> PhonemesToID(const std::string& InTxt);2324std::vector<std::string> Speakers;25std::vector<std::string> Emotions;2627void ReadPhonemes(const std::string& PhonemePath);2829void ReadSpeakers(const std::string& SpeakerPath);3031void ReadEmotions(const std::string& EmotionPath);323334void ReadModelInfo(const std::string& ModelInfoPath);3536std::vector<std::string> GetLinedFile(const std::string& Path);373839std::string ModelInfo;4041public:42/* Voice constructor, arguments obligatory.43-> VoxPath: Path of folder where models are contained.44-- Must be a folder without an ending slash with UNIX slashes, can be relative or absolute (eg: MyVoices/Karen)45-- The folder must contain the following elements:46--- melgen: Folder generated where a FastSpeech2 model was saved as SavedModel, with .pb, variables, etc47--- vocoder: Folder where a Multi-Band MelGAN model was saved as SavedModel.48--- info.json: Model information49--- phonemes.txt: Tab delimited file containing PHONEME \t ID, for inputting to the FS2 model.5051--- If multispeaker, a lined .txt file called speakers.txt52--- If multi-emotion, a lined .txt file called emotions.txt5354*/55Voice(const std::string& VoxPath, const std::string& inName,Phonemizer* InPhn);5657void AddPhonemizer(Phonemizer* InPhn);585960std::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);6162std::string Name;63inline const VoiceInfo& GetInfo(){return VoxInfo;}6465inline const std::vector<std::string>& GetSpeakers(){return Speakers;}66inline const std::vector<std::string>& GetEmotions(){return Emotions;}6768inline const std::string& GetModelInfo(){return ModelInfo;}6970~Voice();71};72737475