1 /* Copyright (C) 2012, 2016  Olga Yakovleva <yakovleva.o.v@gmail.com> */
2 
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU Lesser General Public License as published by */
5 /* the Free Software Foundation, either version 2.1 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
11 /* GNU Lesser General Public License for more details. */
12 
13 /* You should have received a copy of the GNU Lesser General Public License */
14 /* along with this program.  If not, see <http://www.gnu.org/licenses/>. */
15 
16 #ifndef RHVOICE_HTS_LABELLER_HPP
17 #define RHVOICE_HTS_LABELLER_HPP
18 
19 #include <string>
20 #include <vector>
21 
22 #include "exception.hpp"
23 
24 namespace RHVoice
25 {
26   class item;
27   class feature_function;
28 
29   class hts_feature_undefined: public lookup_error
30   {
31   public:
hts_feature_undefined(const std::string & name)32     hts_feature_undefined(const std::string& name):
33       lookup_error("This hts feature has not been defined: "+name)
34     {
35     }
36   };
37 
38   class hts_labeller
39   {
40   public:
hts_labeller(const std::string & file_path)41     explicit hts_labeller(const std::string& file_path)
42     {
43       load_label_format_description(file_path);
44       define_default_features();
45     }
46 
47     void define_feature(const std::shared_ptr<feature_function>& f);
48     void define_extra_phonetic_feature(const std::string& name);
49     std::string eval_segment_label(const item& seg) const;
50 
51   private:
52     void load_label_format_description(const std::string& file_path);
53     void define_default_features();
54 
55     struct hts_feature
56     {
57       std::string name,prefix;
58       std::shared_ptr<feature_function> function;
59     };
60 
61     std::vector<hts_feature> features;
62   };
63 }
64 #endif
65