Skip to content

Commit c13f1a3

Browse files
committed
Added calls for GetSupportedLanguages, GetSupportedSpeechStyles, and GetSupportedBrailleCodes.
Added tests for them.
1 parent 6b16037 commit c13f1a3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Example/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ def test():
6363

6464
mathml = "<math><mfrac> <mn>1</mn> <mi>X</mi> </mfrac> </math>"
6565
setMathMLForMathCAT(mathml)
66+
67+
languages = libmathcat.GetSupportedLanguages()
68+
if "en" not in languages:
69+
sys.exit(f"Supported languages does not include 'en': {languages}")
70+
speech_styles = libmathcat.GetSupportedSpeechStyles("en")
71+
if "SimpleSpeak" not in speech_styles or "ClearSpeak" not in speech_styles:
72+
sys.exit(f"Supported speech styles does not include 'SimpleSpeak' and/or 'ClearSpeak': {speech_styles}")
73+
braille_codes = libmathcat.GetSupportedBrailleCodes()
74+
if "UEB" not in braille_codes or "Nemeth" not in braille_codes:
75+
sys.exit(f"Supported languages does not include 'UEB' and/or 'Nemeth': {braille_codes}")
6676
speech = getSpeech()
6777
if speech != "1 over cap x":
6878
sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")

src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ pub fn GetVersion(_py: Python) -> PyResult<String> {
6464
return Ok( get_version() );
6565
}
6666

67+
#[pyfunction]
68+
/// Returns a list of all supported languages (["en", "es", ...])
69+
pub fn GetSupportedLanguages(_py: Python) -> PyResult<Vec<String>> { // type in Python is list[str]
70+
return Ok( get_supported_languages() )
71+
}
72+
73+
#[pyfunction]
74+
/// Returns a list of all supported speech styles given a language (["ClearSpeak", "SimpleSpeak", ...])
75+
pub fn GetSupportedSpeechStyles(_py: Python, lang: String) -> PyResult<Vec<String>> { // type in Python is list[str]
76+
return Ok( get_supported_speech_styles(lang) );
77+
}
78+
79+
#[pyfunction]
80+
/// Returns a list of all supported braille codes (["UEB", "Nemeth", ...])
81+
pub fn GetSupportedBrailleCodes(_py: Python) -> PyResult<Vec<String>> { // type in Python is list[str]
82+
return Ok( get_supported_braille_codes() );
83+
}
84+
6785
#[pyfunction]
6886
/// Get the spoken text of the MathML that was set.
6987
/// The speech takes into account any AT or user preferences.
@@ -160,6 +178,9 @@ fn libmathcat_py(m: &Bound<'_, PyModule>) -> PyResult<()> {
160178
m.add_function(wrap_pyfunction!(SetRulesDir, m)?)?;
161179
m.add_function(wrap_pyfunction!(SetMathML, m)?)?;
162180
m.add_function(wrap_pyfunction!(GetVersion, m)?)?;
181+
m.add_function(wrap_pyfunction!(GetSupportedLanguages, m)?)?;
182+
m.add_function(wrap_pyfunction!(GetSupportedSpeechStyles, m)?)?;
183+
m.add_function(wrap_pyfunction!(GetSupportedBrailleCodes, m)?)?;
163184
m.add_function(wrap_pyfunction!(GetSpokenText, m)?)?;
164185
m.add_function(wrap_pyfunction!(SetPreference, m)?)?;
165186
m.add_function(wrap_pyfunction!(GetPreference, m)?)?;

0 commit comments

Comments
 (0)