1 /* Copyright (C) 2013, 2020 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_LABEL_HPP 17 #define RHVOICE_HTS_LABEL_HPP 18 19 #include <string> 20 #include <list> 21 #include "item.hpp" 22 #include "relation.hpp" 23 #include "utterance.hpp" 24 #include "hts_labeller.hpp" 25 #include "property.hpp" 26 27 namespace RHVoice 28 { 29 class hts_label 30 { 31 public: hts_label(const item & segment_)32 explicit hts_label(const item& segment_): 33 segment(&segment_), 34 time(-1), 35 duration(0), 36 position(-1), 37 length(0) 38 { 39 } 40 41 const std::string& get_name() const; 42 43 double get_rate() const; 44 double get_pitch() const; 45 double get_volume() const; 46 bool is_marked_by_sound_icon() const; 47 set_time(int time_)48 void set_time(int time_) // in samples 49 { 50 time=time_; 51 } 52 get_time() const53 int get_time() const 54 { 55 return time; 56 } 57 set_position(int position_)58 void set_position(int position_) // in frames 59 { 60 position=position_; 61 } 62 get_position() const63 int get_position() const 64 { 65 return position; 66 } 67 set_duration(int dur)68 void set_duration(int dur) // in samples 69 { 70 duration=dur; 71 } 72 get_duration() const73 int get_duration() const 74 { 75 return duration; 76 } 77 set_length(int dur)78 void set_length(int dur) // in frames 79 { 80 length=dur; 81 } 82 get_length() const83 int get_length() const 84 { 85 return length; 86 } 87 get_segment() const88 const item& get_segment() const 89 { 90 return *segment; 91 } 92 93 private: 94 double calculate_speech_param(double absolute_change,double relative_change,const numeric_property<double>& default_value,const numeric_property<double>& min_value,const numeric_property<double>& max_value,bool clip) const; 95 96 const item* get_token() const; 97 98 const item* segment; 99 mutable std::string name; 100 int time,duration,position,length; 101 }; 102 103 typedef std::list<hts_label> label_sequence; 104 } 105 #endif 106