示例#1
0
文件: english.cpp 项目: denji/RHVoice
 void english::correct_pronunciation_of_articles(utterance& u) const
 {
   relation& trans_rel=u.get_relation("Transcription");
   for(relation::iterator word_iter(trans_rel.begin());word_iter!=trans_rel.end();++word_iter)
     {
       const std::string& word_name=word_iter->get("name").as<std::string>();
       item& seg=word_iter->last_child().as("Segment");
       if(word_name=="the")
         {
           if(seg.eval("n.ph_vc").as<std::string>()=="+")
             seg.set<std::string>("name","iy");
         }
       else
         {
           if((word_name=="a")&&
              ((!word_iter->as("Phrase").has_next())||
               word_iter->has_feature("lseq")))
             {
               seg.set<std::string>("name","ey");
               seg.as("SylStructure").parent().set<std::string>("stress","1");
               word_iter->set<std::string>("gpos","content");
             }
         }
     }
 }
示例#2
0
文件: english.cpp 项目: denji/RHVoice
 void english::correct_pronunciation_of_contractions(utterance& u) const
 {
   std::string manner,place;
   relation& trans_rel=u.get_relation("Transcription");
   for(relation::iterator word_iter(trans_rel.begin());word_iter!=trans_rel.end();++word_iter)
     {
       const std::string& word_name=word_iter->get("name").as<std::string>();
       item& seg=word_iter->last_child().as("Segment");
       bool insert_schwa=false;
       if(word_name=="\'s")
         {
           manner=seg.eval("p.ph_ctype").as<std::string>();
           place=seg.eval("p.ph_cplace").as<std::string>();
           insert_schwa=(((manner=="f")||(manner=="a"))&&((place=="a")||(place=="p")));
         }
       else
         insert_schwa=((word_name=="\'d")||(word_name=="\'ll")||(word_name=="\'ve"));
       if(insert_schwa)
         {
           item& schwa=seg.prepend();
           schwa.set<std::string>("name","ax");
           seg.as("Transcription").prepend(schwa);
           seg.as("SylStructure").prepend(schwa);
         }
       if((word_name=="\'s")&&
          ((seg.eval("p.ph_vc").as<std::string>()=="+")||
           (seg.eval("p.ph_cvox").as<std::string>()=="+")))
         seg.set<std::string>("name","z");
     }
 }
示例#3
0
文件: english.cpp 项目: denji/RHVoice
 void english::predict_accents_and_tones(utterance& u) const
 {
   relation& syl_rel=u.get_relation("Syllable");
   for(relation::iterator syl_iter(syl_rel.begin());syl_iter!=syl_rel.end();++syl_iter)
     {
       if(accents_dtree.predict(*syl_iter).as<std::string>()!="NONE")
         syl_iter->set<std::string>("accented","1");
       else
         syl_iter->set<std::string>("accented","0");
       syl_iter->set("endtone",tones_dtree.predict(*syl_iter));
     }
 }
示例#4
0
 sentence_event(const utterance& utt)
 {
   const relation& token_rel=utt.get_relation("Token");
   text_start=token_rel.first().get("position").as<std::size_t>();
   text_length=token_rel.last().get("position").as<std::size_t>()+token_rel.last().get("length").as<std::size_t>()-text_start;
 }