void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain) { int i; synthesise(fft_inv_cfg, Sn_, model, Pn, 1); if (prede) de_emp(Sn_, Sn_, de_mem, N); for(i=0; i<N; i++) { Sn_[i] *= gain; if (Sn_[i] > 32767.0) buf[i] = 32767; else if (Sn_[i] < -32767.0) buf[i] = -32767; else buf[i] = Sn_[i]; } }
int main(int argc, char *argv[]) { FILE *fin, *fout; short buf[N]; float Sn[N], Sn_de[N]; float de_mem = 0.0; int i; if (argc != 3) { printf("usage: de InputRawSpeechFile OutputRawSpeechFile\n"); printf("e.g de input.raw output.raw"); exit(1); } if (strcmp(argv[1], "-") == 0) fin = stdin; else if ( (fin = fopen(argv[1],"rb")) == NULL ) { fprintf(stderr, "Error opening input speech file: %s: %s.\n", argv[1], strerror(errno)); exit(1); } if (strcmp(argv[2], "-") == 0) fout = stdout; else if ( (fout = fopen(argv[2],"wb")) == NULL ) { fprintf(stderr, "Error opening output speech file: %s: %s.\n", argv[2], strerror(errno)); exit(1); } while(fread(buf, sizeof(short), N, fin) == N) { for(i=0; i<N; i++) Sn[i] = buf[i]; de_emp(Sn_de, Sn, &de_mem, N); for(i=0; i<N; i++) buf[i] = Sn_de[i]; fwrite(buf, sizeof(short), N, fout); } fclose(fin); fclose(fout); return 0; }