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

Function speak

src/navigate.rs:502–527  ·  view source on GitHub ↗
(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>, nav_node_id: String, full_read: bool)

Source from the content-addressed store, hash-verified

500}
501
502fn speak<'r, 'c, 's:'c, 'm:'c>(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>, nav_node_id: String, full_read: bool) -> Result<String> {
503 if full_read {
504 let intent = crate::speech::intent_from_mathml(mathml, rules_with_context.get_document())?;
505 debug!("intent: {}", mml_to_string(&intent));
506
507 // In something like x^3, we might be looking for the '3', but it will be "cubed", so we don't find it.
508 // Or we might be on a "(" surrounding a matrix and that isn't part of the intent
509 // We are probably safer in terms of getting the same speech if we retry intent starting at the nav node,
510 // but the node to speech is almost certainly trivial.
511 // By speaking the non-intent tree, we are certain to speech on the next try
512 if get_node_by_id(intent, &nav_node_id).is_some() {
513 match crate::speech::speak_mathml(intent, &nav_node_id) {
514 Ok(speech) => return Ok(speech),
515 Err(e) => {
516 if e.to_string() != crate::speech::NAV_NODE_SPEECH_NOT_FOUND {
517 return Err(e);
518 }
519 // else could be something like '3' in 'x^3' ("cubed")
520 },
521 }
522 }
523 return crate::speech::speak_mathml(mathml, &nav_node_id);
524 } else {
525 return crate::speech::overview_mathml(mathml, &nav_node_id);
526 }
527}
528
529
530// MathPlayer's interface mentions these, so we keep them.

Callers 1

apply_navigation_rulesFunction · 0.85

Calls 5

intent_from_mathmlFunction · 0.85
get_node_by_idFunction · 0.85
speak_mathmlFunction · 0.85
overview_mathmlFunction · 0.85
get_documentMethod · 0.80

Tested by

no test coverage detected