LaSpeak: LaTeX Conversion to XML-Based Speech

LaSpeak is a system for translating LaTeX sources into XML files of speech formats. The conversions are achieved through TeX4ht. Currently the system supports translations to the Java Speech Markup Language (JSML) format and to the Aural Cascading Style Sheets (ACSS) format of emacspeak.

Using the System

Conversions of source LaTeX files can be requested through variations of the following command line

commandName filename "options1" "option2" "options3" "options4"

where for JSML output the commandName should be jslatex, and for the emacspeak variant of ACSS the commandName should be eslatex. For instance,

jslatex  filename  
eslatex  filename "html,3,next"

The available options are inherited from the TeX4ht environment. The jslatex command is a shortcut of the TeX4ht command ‘htlatex filename "xhtml,jsml" " -cjsmlhtf" "-cjsml"’. The eslatex command is a shortcut of the TeX4ht command ‘htlatex filename "xhtml,emspk" " -cemspkhtf -s4es" "-cemspk"’.


The conversion environment is fully included within the TeX4ht installation.

JSML Speaker

A java program similar to listed below may be used to speak, but not browse, JSML files.


javac -classpath foosapi.jar


java -classpath ".;foosapi.jar" JSpeak filename

The foosapi.jar file should be an implementation of JSAPI that supports JSML. The cgjsapi.jar implementation from is a possible candidate for Microsoft Windows.

 import javax.speech.*;
 import javax.speech.synthesis.*;
 import java.util.Locale;
 public class JSpeak{
    public static void main(String args[]) {
      try {
         Synthesizer synth = Central.createSynthesizer(
                       new SynthesizerModeDesc(Locale.ENGLISH));
            String data = load( args[0] );
            synth.speak(data, null);                       // jsml file
         } catch( Exception e1 ){
               String data = load( args[0] );
                  + data.replaceFirst("<[?]xml.*[?]>", "") // xml file
                  + "</jsml>", null);
            } catch( Exception e2 ){
               String data = load( args[0] );
               synth.speakPlainText(data, null);           // text file
         }  }
      } catch( Exception e4 ){
         System.err.print("--- Error --- "); e4.printStackTrace();
    } }
    static String load( String file ) throws Exception {
      String data = "", s;
      FileReader fr  = new FileReader( file );
      BufferedReader myIn = new BufferedReader( fr );
      while( (s=myIn.readLine()) != null ){ data += s; }
      return data;
 }  }

Bug Reports

The development of the LaSpeak system will to a large degree be driven by users’ suggestions and bug reports. In most cases, when providing feedback, it is essential to include the following information.


LaSpeak is provided under the LaTeX Project Public License (LPPL).



I am very grateful to Daniel A. Galron for introducing me to the field of speech technologies, and for setting up for me a computing environemt to work with speech. The LaSpeak system is a side byproduct of a work devoted to translations into braille. I am very thankful to Susan Jolly for suggesting me the braille project, for introducing me to braille, and for her generous guidance and help.

This work was partially sponsored by NSF grant IIS-0312487. Any opinions, findings, and conclusions or recommendations expressed in this work are those of the authors and do not necessarily reflect the views of the National Science Foundation.

Eitan M. Gurari
August 19, 2007