-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneural-g2p.h
More file actions
35 lines (28 loc) · 798 Bytes
/
Copy pathneural-g2p.h
File metadata and controls
35 lines (28 loc) · 798 Bytes
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
#pragma once
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
enum class G2PBackend { AUTO, NEURAL, ESPEAK };
#ifdef __APPLE__
#import <CoreML/CoreML.h>
class NeuralG2P {
public:
~NeuralG2P();
bool load(const std::string& mlmodelc_path);
std::string phonemize(const std::string& text);
bool is_available() const { return available_; }
private:
std::string phonemize_word(const std::string& word);
MLModel* model_ = nil;
bool available_ = false;
bool needs_lengths_ = true;
int pad_idx_ = 0;
int unk_idx_ = 1;
int eos_idx_ = 2;
int phoneme_pad_idx_ = 0;
mutable std::mutex predict_mutex_;
std::unordered_map<std::string, int> char_vocab_;
std::vector<std::string> phoneme_vocab_;
};
#endif // __APPLE__