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

Method get_string_sapi5

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

Source from the content-addressed store, hash-verified

508 }
509
510 fn get_string_sapi5(&self, command: &TTSCommandRule, prefs: &PreferenceManager, is_start_tag: bool) -> String {
511 return match &command.command {
512 TTSCommand::Pause => if is_start_tag {
513 let amount = command.value.get_num();
514 if amount == PAUSE_AUTO {
515 PAUSE_AUTO_STR.to_string()
516 } else {
517 let amount = amount * TTS::get_pause_multiplier(prefs);
518 if amount > MIN_PAUSE {
519 format!("<silence msec=='{}ms'/>", (amount * 180.0/prefs.get_rate()).round())
520 } else {
521 "".to_string()
522 }
523 }
524 } else {
525 "".to_string()
526 },
527 // pitch must be in [-10, 10], logarithmic based on octaves
528 // note MathPlayer uses 'absmiddle' (requires keeping a stack) -- could be 'middle' is not well supported
529 TTSCommand::Pitch => if is_start_tag {format!("<pitch middle=\"{}\">", (24.0*(1.0+command.value.get_num()/100.0).log2()).round())} else {String::from("</prosody>")},
530 // rate must be in [-10, 10], but we get relative %s. 300% => 10 (see comments at top of file)
531 TTSCommand::Rate => if is_start_tag {format!("<rate speed='{:.1}'>", 10.0*(0.01*command.value.get_num()).log(3.0))} else {String::from("</rate>")},
532 TTSCommand::Volume =>if is_start_tag {format!("<volume level='{}'>", command.value.get_num())} else {String::from("</volume>")},
533 TTSCommand::Audio => "".to_string(), // SAPI5 doesn't support audio
534 TTSCommand::Gender =>if is_start_tag {format!("<voice required=\"Gender={}\">", command.value.get_string())} else {String::from("</prosody>")},
535 TTSCommand::Voice =>if is_start_tag {format!("<voice required=\"Name={}\">", command.value.get_string())} else {String::from("</prosody>")},
536 TTSCommand::Spell =>if is_start_tag {format!("<spell>{}", command.value.get_string())} else {String::from("</spell>")},
537 TTSCommand::Pronounce =>if is_start_tag {
538 format!("<pron sym='{}'>{}", &command.value.get_pronounce().sapi5, &command.value.get_pronounce().text)
539 } else {
540 String::from("</pron>")
541 },
542 TTSCommand::Bookmark => panic!("Internal error: bookmarks should have been handled earlier"),
543 };
544 }
545
546 fn get_string_ssml(&self, command: &TTSCommandRule, prefs: &PreferenceManager, is_start_tag: bool) -> String {
547 return match &command.command {

Callers 2

replace_stringMethod · 0.80
compute_auto_pauseMethod · 0.80

Calls 1

get_numMethod · 0.80

Tested by

no test coverage detected