File size: 1,129 Bytes
d5ee97c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#ifndef TTSFRONTEND_H
#define TTSFRONTEND_H

#include <iostream>
#include <string>
#include <vector>
#include <regex>
#include <stdio.h>

class TTSFrontend
{
public:

    /**
     * Converting text to phoneIDs. 
     * A tmporary method using command to process text in this demo, 
     * which should to be replaced by a pronunciation processing module.
     *@param strCmd Command to call the method of processor.text_to_sequence()
    */
    TTSFrontend(const std::string &mapperJson,
               const std::string &strCmd):
               _mapperJson(mapperJson),
               _strCmd(strCmd)
    {
        std::cout << "TTSFrontend Init" << std::endl;
        std::cout << _mapperJson << std::endl;
        std::cout << _strCmd << std::endl;
    };

    void text2ids(const std::string &text);

    std::vector<int32_t> getPhoneIds() const {return _phonesIds;}
private:

    const std::string _mapperJson;
    const std::string _strCmd;

    std::vector<int32_t> _phonesIds;

    std::string getCmdResult(const std::string &text);
    std::vector<int32_t> strSplit(const std::string &idStr);
};

#endif // TTSFRONTEND_H