<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span><br></span></div><br><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;">The code i used for decoding is given below:<br><br>#include &lt;jni.h&gt;<br>#include &lt;stdio.h&gt;<br>#include "speex/speex.h"<br><br>&nbsp;#define FRAME_SIZE 160<br><br><br>void Java_com_m2_iSmartDm_ISmartDMActivity_spxDec(JNIEnv * env, jobject jobj,jstring dir1,jstring dir2)<br>{<br>&nbsp;&nbsp;&nbsp; const char *inFile= (*env)-&gt;GetStringUTFChars(env,dir1,0);<br>&nbsp;&nbsp;&nbsp; const char *outFile= (*env)-&gt;GetStringUTFChars(env,dir2,0);<br>&nbsp;&nbsp;&nbsp; FILE *fin;<br>&nbsp;&nbsp;&nbsp; FILE *fout;<br>&nbsp;/*Holds the audio that will be written to file (16 bits per sample)*/<br>&nbsp;short out[FRAME_SIZE];<br>&nbsp;/*Speex handle
 samples as float, so we need an array of floats*/<br>&nbsp;float output[FRAME_SIZE];<br>&nbsp;char cbits[200];<br>&nbsp;int nbBytes;<br>&nbsp;/*Holds the state of the decoder*/<br>&nbsp;void *state;<br>&nbsp;/*Holds bits so they can be read and written to by the Speex routines*/<br>&nbsp;SpeexBits bits;<br>&nbsp;int i, tmp;<br><br>&nbsp;/*Create a new decoder state in narrowband mode*/<br>&nbsp; state = speex_decoder_init(&amp;speex_nb_mode);<br><br>&nbsp; /*Set the perceptual enhancement on*/<br>&nbsp; tmp=1;<br>&nbsp; speex_decoder_ctl(state, SPEEX_SET_ENH, &amp;tmp);<br><br>&nbsp; fin = fopen(inFile, "r");<br>&nbsp; fout=fopen(outFile,"w");<br><br>&nbsp; speex_bits_init(&amp;bits);<br><br>&nbsp; while (1)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; /*Read the size encoded by sampleenc, this part will likely be<br>&nbsp;&nbsp; different in your application*/<br>&nbsp;&nbsp; fread(&amp;nbBytes, sizeof(int), 1, fin);<br>&nbsp;&nbsp; if
 (feof(stdin))<br>&nbsp;&nbsp;&nbsp; break;<br><br>&nbsp;&nbsp; /*Read the "packet" encoded by sampleenc*/<br>&nbsp;&nbsp; fread(cbits, 1, nbBytes, fin);<br><br>&nbsp;&nbsp; /*Copy the data into the bit-stream struct*/<br>&nbsp;&nbsp; speex_bits_read_from(&amp;bits, cbits, nbBytes);<br><br>&nbsp;&nbsp; /*Decode the data*/<br>&nbsp;&nbsp;&nbsp; speex_decode(state, &amp;bits, output);<br><br>&nbsp;&nbsp;&nbsp; /*Copy from float to short (16 bits) for output*/<br>&nbsp;&nbsp;&nbsp;&nbsp; for (i=0;i&lt;FRAME_SIZE;i++)<br>&nbsp;&nbsp;&nbsp;&nbsp; out[i]=output[i];<br><br>&nbsp;&nbsp;&nbsp;&nbsp; /*Write the decoded audio to file*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fwrite(out, sizeof(short), FRAME_SIZE, fout);<br><br>&nbsp;&nbsp; }<br>&nbsp; /*Destroy the decoder state*/<br>&nbsp;&nbsp; speex_decoder_destroy(state);<br>&nbsp;&nbsp; /*Destroy the bit-stream truct*/<br>&nbsp;&nbsp; speex_bits_destroy(&amp;bits);<br>&nbsp;&nbsp; fclose(fout);<br>&nbsp;&nbsp;
 fclose(fin);<br><br>Please check this code and correct me. Thanks<br>} <br> </div> </div>  </div></body></html>