-
Notifications
You must be signed in to change notification settings - Fork 20
/
espeakphonemizer.h
47 lines (33 loc) · 1.16 KB
/
espeakphonemizer.h
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
#ifndef ESPEAKPHONEMIZER_H
#define ESPEAKPHONEMIZER_H
/*
ESpeakPhonemizer: Tool for IPA Text2Phon using ESpeak NG as backend.
*/
#include <iostream>
#include <string>
#include <bitset>
#include "VoxCommon.hpp"
#include <vector>
namespace ESP{
typedef std::pair<bool, std::u32string> PunctSplit;
typedef std::vector<PunctSplit> PunctSplitVec;
// Returns vector<pair<IS_PUNCTUATION,String>>
PunctSplitVec IterativePunctuationSplit(const std::u32string& Input, const std::u32string& Punct);
}
class ESpeakPhonemizer
{
private:
std::bitset<sizeof(int) * 8> PhonemePars;
std::string ToPhon(const std::string& InTxt);
std::string EVoiceName;
public:
// DataPath: Path to ESpeak NG data dir
// VoiceName: Name of voice to use for phonemizing (like "Spanish (Latin America)")
void Initialize(const std::string& DataPath,const std::string& VoiceName);
// Phonemize text using ESpeak phonemizer
// Unlike regular phonemizer, feed complete texts at once instead of just words.
std::string Phonemize(const std::string& Input);
ESpeakPhonemizer();
const std::string& GetVoiceName() const {return EVoiceName;};
};
#endif // ESPEAKPHONEMIZER_H