MCPcopy Create free account
hub / github.com/daisy/MathCAT / get_string_ssml

Method get_string_ssml

src/tts.rs:546–579  ·  view source on GitHub ↗
(&self, command: &TTSCommandRule, prefs: &PreferenceManager, is_start_tag: bool)

Source from the content-addressed store, hash-verified

544 }
545
546 fn get_string_ssml(&self, command: &TTSCommandRule, prefs: &PreferenceManager, is_start_tag: bool) -> String {
547 return match &command.command {
548 TTSCommand::Pause => {
549 if is_start_tag {
550 let amount = command.value.get_num();
551 if amount == PAUSE_AUTO {
552 PAUSE_AUTO_STR.to_string()
553 } else {
554 let amount = amount * TTS::get_pause_multiplier(prefs);
555 if amount > MIN_PAUSE {
556 format!("<break time='{}ms'/>", (amount * 180.0/prefs.get_rate()).round())
557 } else {
558 "".to_string()
559 }
560 }
561 } else {
562 "".to_string()
563 }
564 },
565 TTSCommand::Pitch => if is_start_tag {format!("<prosody pitch='{}%'>", command.value.get_num())} else {String::from("</prosody>")},
566 TTSCommand::Rate => if is_start_tag {format!("<prosody rate='{}%'>", command.value.get_num())} else {String::from("</prosody>")},
567 TTSCommand::Volume =>if is_start_tag {format!("<prosody volume='{}db'>", command.value.get_num())} else {String::from("</prosody>")},
568 TTSCommand::Audio =>if is_start_tag {format!("<audio src='{}'>", command.value.get_string())} else {String::from("</audio>")}, // only 'beep' is supported for now
569 TTSCommand::Gender =>if is_start_tag {format!("<voice required='gender=\"{}\"'>", command.value.get_string())} else {String::from("</voice>")},
570 TTSCommand::Voice =>if is_start_tag {format!("<voice required='{}'>", command.value.get_string())} else {String::from("</voice>")},
571 TTSCommand::Spell =>if is_start_tag {format!("<say-as interpret-as='characters'>{}", command.value.get_string())} else {String::from("</say-as>")},
572 TTSCommand::Pronounce =>if is_start_tag {
573 format!("<phoneme alphabet='ipa' ph='{}'>{}", &command.value.get_pronounce().ipa, &command.value.get_pronounce().text)
574 } else {
575 String::from("</phoneme>")
576 },
577 TTSCommand::Bookmark => panic!("Internal error: bookmarks should have been handled earlier"),
578 }
579 }
580
581 fn get_pause_multiplier(prefs: &PreferenceManager) -> f64 {
582 return prefs.pref_to_string("PauseFactor").parse::<f64>().unwrap_or(100.)/100.0;

Callers 2

replace_stringMethod · 0.80
compute_auto_pauseMethod · 0.80

Calls 1

get_numMethod · 0.80

Tested by

no test coverage detected