st = speex_resampler_init(1, 16000, 8000, 10, &err);
do{
readlen = fread(in, sizeof(short), 1024, fin);
if (readlen > 0)
{
inlen = readlen;
outlen = 1024;
ret = speex_resampler_process_int(st, 0, in, &inlen, out, &outlen);
if (ret == RESAMPLER_ERR_SUCCESS)
{
fwrite(out, sizeof(short), outlen, fout);
}
}
}while(readlen == 1024);
speex_resampler_destroy(st); |