<div dir="ltr"><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">hi</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">we are trying to decode
speech that was encoded on a ds'pic with a NB 8 Kb/sec.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> we wrote a simple
program using the API speex lib 1.2 beta 3:</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#include
"stdafx.h"</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#include
<iostream></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#include <stdio.h></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#include
"speex.h"</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#include
"speex_bits.h"</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">using namespace std;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">char hex2ascii(char
toconv);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#define FRAME_SIZE 160</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">#define nbBytes 20</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">int main(int argc,
_TCHAR* argv[])</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">int mode = 3; </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">int i=0,j=0; </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">char ch=0;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">int in=0,temp=0;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">char out_ascii[640]={0};</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">float output[FRAME_SIZE];//the
originals 160 words in float</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">short
out[FRAME_SIZE];//the originals 160 words</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">char cbits[nbBytes];</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">void *state;//hold the
state of the decoder</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">SpeexMode speex_nb_mode;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">SpeexBits bits;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">state=decoder_init_func(&
speex_nb_mode);//initializing a speex decoder</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">speex_decoder_ctl(state,SPEEX_SET_MODE,&temp);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">speex_bits_init(&bits); </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">we get the data throw
RS232, and convert the decoded (supose to be the original or close to it) to
ASCII, so we can simply play it in MATLAB: </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">system("mode com1:
baud=38400 parity=n data=8 stop=1");//opening the rs232</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">FILE*
mic=fopen("com1:", "w+" );</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">FILE *mic1 =
fopen("mic.txt" , "wt");</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">while(1)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">if (feof( mic ) == 0){</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">cbits[i]=fgetc(mic);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">if(i==20)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">speex_bits_read_from(&bits,
cbits, nbBytes); </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">i=0;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">speex_decode(state,
&bits, output);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">for
(j=0;j<FRAME_SIZE;j++)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">out[j]=output[j];</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">out_ascii[j*4]=hex2ascii((out[j]
>> 12) & 0x000F); </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">out_ascii[j*4+1]=hex2ascii((out[j]
>> 8) & 0x000F);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">out_ascii[j*4+2]=hex2ascii((out[j]
>> 4) & 0x000F);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">out_ascii[j*4+3]=hex2ascii(out[j]
& 0x000F);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">fputs(out_ascii,mic1); </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">else{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">i++;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">fclose( mic );</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">fclose( mic1 );</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">return 0;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">char hex2ascii(char
toconv)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">if
(toconv<0x0A) </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">toconv += 0x30;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">else </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">{</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">toconv += 0x37;</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">return (toconv);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">the program give as an
error message:</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">"<i>Unhandled
exception at 0x1000b65a in new_speex.exe: 0xC0000005: Access violation reading
location 0xccccccfc.</i>"</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">we dont undersand why,
maybe we are not on the correct NB mode?</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">we need help!</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">thanks</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">shlomo and eitan</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";color:black">EE students in israel<br clear="all" style="mso-special-character:line-break">
</span></p>
<p class="MsoNormal"> </p></span></font></div>