@@ -56,7 +56,8 @@ Convert.setupSre = function() {
5656} ;
5757
5858Convert . init = function ( ) {
59- SRE = MathJax . _ . a11y . sre . Sre ;
59+ SRE = MathJax . _ . a11y . sre_ts ;
60+ MathJax . startup . document . getWebworker ( ) ;
6061 Convert . getElements ( ) ;
6162 Convert . setupSre ( ) ;
6263} ;
@@ -80,12 +81,18 @@ Convert.preferenceSelection = function(pref, values) {
8081 } ) ;
8182} ;
8283
83- Convert . setPreferences = function ( locale ) {
84+ Convert . setPreferences = async function ( locale ) {
8485 const container = Convert . divs . preferences ;
8586 container . innerHTML = '' ;
8687 Convert . state . preferences = [ ] ;
8788
88- const prefs = SRE . clearspeakPreferences . getLocalePreferences ( ) [ locale ] ;
89+ const map = new Map ( ) ;
90+ const mdoc = MathJax . startup . document ;
91+ mdoc . options . sre . locale = locale
92+ await mdoc . webworker . Setup ( mdoc . options . sre ) ;
93+ await mdoc . webworker . clearspeakLocalePreferences ( mdoc . options . sre , map ) ;
94+ const prefs = map . get ( locale ) ;
95+
8996 if ( ! prefs ) {
9097 Convert . state . clearspeak = false ;
9198 Convert . textAreas . clearspeak . innerHTML = '' ;
@@ -160,20 +167,19 @@ Convert.setPreferences = function(locale) {
160167 }
161168} ;
162169
163- Convert . updatePreferences = async function ( locale ) {
164- return SRE . setupEngine ( { locale : locale } )
165- . then ( ( ) => Convert . setPreferences ( locale ) ) ;
170+ Convert . updatePreferences = function ( locale ) {
171+ return Convert . setPreferences ( locale ) ;
166172} ;
167173
168174
169- Convert . computeClearspeak = async function ( ) {
175+ Convert . computeClearspeak = function ( ) {
170176 return Convert . computeSpeech (
171177 Convert . textAreas . clearspeak , 'clearspeak' ,
172178 Convert . state . preferences . map ( ( x ) => x . value ) . join ( ':' ) ) ;
173179} ;
174180
175181
176- Convert . computeMathspeak = async function ( ) {
182+ Convert . computeMathspeak = function ( ) {
177183 return Convert . computeSpeech (
178184 Convert . textAreas . mathspeak , 'mathspeak' , Convert . selectors . style . value ) ;
179185} ;
@@ -182,10 +188,28 @@ Convert.computeMathspeak = async function() {
182188Convert . computeSpeech = async function ( node , domain , style ) {
183189 const locale = Convert . selectors . locale . value ;
184190 const modality = locale === 'nemeth' ? 'braille' : 'speech' ;
185- return SRE . setupEngine (
186- { locale : locale , domain : domain , modality : modality ,
187- style : style , markup : Convert . selectors . markup . value , pprint : true
188- } ) . then ( ( ) => node . innerHTML = SRE . toSpeech ( Convert . input2Mathml ( ) ) ) ;
191+ const mdoc = MathJax . startup . document ;
192+ const options = mdoc . options . sre = { ...mdoc . options . sre ,
193+ locale, domain, modality, style, markup : Convert . selectors . markup . value , pprint : true
194+ } ;
195+ await mdoc . webworker . Setup ( options ) ;
196+ const data = JSON . parse ( await mdoc . webworker . Post ( {
197+ cmd : 'speech' ,
198+ data : {
199+ mml : Convert . input2Mathml ( ) ,
200+ options : options
201+ }
202+ } ) ) ;
203+ node . innerHTML = options . markup === 'ssml'
204+ ? [
205+ '<!--?xml version="1.0"?-->\n' ,
206+ '<speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis">' ,
207+ '<prosody rate="100%">' ,
208+ data . ssml ,
209+ '</prosody>' ,
210+ '</speak>'
211+ ] . join ( '' )
212+ : data . label ;
189213} ;
190214
191215
0 commit comments