SDK |
Documentation |
JavaSonics ListenUp is no longer for sale.Converting Speex to WAV Files on your ServerSpeex is a handy format for uploading and storing voice data because it is so small. But not every program can read Speex files. If you want to send someone a message as an email attachment, or import the message into an audio editor, then you might need to convert the Speex file to a WAV file. ListenUp has the ability to decode Speex data, and the ability to write WAV files. We have combined those abilities into a tool called SpeexToWAV. It is a Java application that must be run using a Java virtual machine. You can run this program on your server to convert Speex files to WAV files. Requirements:
How To ConvertAssume you have a Speex file called msgxyz.spx and you want to create a WAV file called outmsg.wav. The application class name is "com.softsynth.javasonics.recplay.SpeexToWAV". Your command line must include this name and a classpath that includes JavaSonicsListenUpUnsigned.jar file and OggXiphSpeexJSUnsigned.jar. The command line finishes with command arguments, as we show below. java -cp codebase/JavaSonicsListenUpUnsigned.jar;codebase/OggXiphSpeexJSUnsigned.jar com.softsynth.javasonics.recplay.SpeexToWAV msgxyz.spx outmsg.wav That must all be on one line. Or you can use a "\" continuation character in Unix. Output CompressionThe output WAV file will be in signed 16 bit format, similar to a CD. You can reduce the size of the output file by a factor of almost 4 by using the IMA ADPCM compression option. Just add "-a" at the end of the command line. Almost every program that can read WAV files supports the IMA ADPCM format. You can also use "-u" for uLaw compression for a factor of 2 size reduction. Some telephony devices require uLaw compression. Restrictions on Command Arguments
Calling from JSPIf you are running JSP on your server, then you can call the SpeexToWAV methods directly. The Java documentation on these methods follows. Note that your JSP should import the converter resource like so: <%@ page import="com.softsynth.javasonics.recplay.SpeexToWAV" %> Note also that you will need to put JavaSonicsListenUpUnsigned.jar file and the OggXiphSpeexJSUnsigned.jar file in YourWebApp/WEB-INF/lib package com.softsynth.javasonics.recplay; /** * Read a Speex stream, decode it and write to a WAV file image stream. * @param inStream Speex input stream * @param outStream WAV output stream * @param format WAVWriter.FORMAT_S16, FORMAT_U8, FORMAT_IMA_ADPCM or FORMAT_ULAW * @throws IOException */ public void convertSpeexToWAV( InputStream inStream, OutputStream outStream, int format ) throws IOException /** * Convert a Speex file to a Wav file. * @param inFile Speex input file, must end with ".spx" * @param outFile WAV output file, must end with ".wav" * @param format WAVWriter.FORMAT_S16, FORMAT_U8, FORMAT_IMA_ADPCM or FORMAT_ULAW * @throws IOException */ public void convertSpeexToWAV( File inFile, File outFile, int format ) throws IOException |