[Speex-dev] Regarding problem with speex library
vijender reddy
vijender at adrin.res.in
Tue Apr 20 20:40:54 PDT 2010
Please ignore this mail if it is duplicate
Hi,
I got the following problem with speex. Could you please help me to resolve the following issue.
Description: I am taking speech input from MIC storing in a buffer after that i will encode by using speex then decoding and sending to output(speakers).
it is small demo project of speech encoding/decoding in VC++.
I am reading the data from buffer in the following way where data is short[] type and buffer is char[].
for(int j=0;j < 160;j++)
data[j]= (buffer[i+j]<<8)^0x8000;
speex_encode_int(state, data, &bits);
nbBytes = speex_bits_write(&bits, cbits, 200);
outbuffer[k]= (char) nbBytes; // Storing length of encoded data first in outbuffer
int writ= k+nbBytes,m=0;
for(k=k+1;k<= writ; k++) // storing the encoded data in outbuffer
outbuffer[k]= cbits[m++];
I am repeatedly doing until the input buffer is over. The encoded data is storing in outbuffer[].
In decoding:
I am reading first byte stored in size variable then reading the data.
psize = buffer[i]; //size of the encoded data frame
j=0;
for(int k=i+1; k <= i+psize;k++)
cbits[j++]= buffer[k]; //Reading encoded data
speex_bits_read_from(&bits, cbits, psize);
/*Decode the frame*/
speex_decode_int(state, &bits, data);
for(k=0;k< 160; k++)
outbuffer[m++]= data[k]; //Storing the decoded frame in char outbuffer[]
After completion of all encoded data. If i play the outbuffer
i am getting full noise. I am hearing voice with very low sound, noise is dominating the speech.
I didn't talk also i am hearing lot of noise from speakers after decoding. I used following preprocess functions also but no use.
int noise_sup=2; // from 2 to 40 and -ve numbers also no use
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noise_sup);
int noise= 1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noise);
int denoise=1;
speex_preprocess_ctl(preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &denoise);
int agc=1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_AGC,&agc);
speex_preprocess_run(preprocess_state,data);
Please help me.
Thanks & regards,
Vijender
More information about the Speex-dev
mailing list