diff -ruN pytsp/pyesd.c pytsp.fixed/pyesd.c --- pytsp/pyesd.c 2005-04-09 15:35:43.000000000 -0700 +++ pytsp.fixed/pyesd.c 2005-04-09 21:24:58.000000000 -0700 @@ -566,44 +566,30 @@ void esd_stop_recording() {stop_recording=1;} -char *esd_record_sound(int len, int rate_hz, int channelsd, int formatd) { - int nread=-1; - char rbuf[ESD_BUF_SIZE]; /* ESD_BUF_SIZE */ - char *rbuf2=rbuf; - char buffer[len+1]; - char *buffer_d=buffer; - int cursor=1; - int copyi; - int space_left; +/* + function: esd_record_sound + rewritten for bug fixes and concise-ness + by Marvin Otto - sivunguvungu at cox.net + on 9 April 2005. + + output: returns a pointer to allocated memory or NULL if error + be sure to free it when finished. +*/ - /* FILE *target; */ - space_left=len-cursor; +char *esd_record_sound(int len, int rate_hz, int channelsd, int formatd) { + char *buffer = NULL; + int cursor = 0; if (init_esd_record( rate_hz, channelsd, formatd)) { - - /* target = fopen( "aggy.raw", "w" ); */ - sprintf(buffer,"%s",""); + buffer = malloc(len + 1); + memset(buffer, 0, len + 1); // ZeroMemory stop_recording=0; - while (space_left>0) { - nread=record(rbuf,ESD_BUF_SIZE); - if (! nread) {break;} - copyi=nread; - if (copyi>space_left) {copyi=space_left;} - - /* fwrite( buf2, 1, nread, target ); */ - strncat(buffer,rbuf,copyi); - cursor=cursor+copyi; - space_left=len-cursor; + while (!stop_recording && (cursor += record(buffer + cursor, len - cursor)) < len) sleep(0.007); - if (stop_recording==1) {break;} - } - /* fclose(target); */ - - - } else {return NULL; } + } - return buffer_d; + return buffer; } @@ -667,7 +653,3 @@ free(myptr); return written; } - - - - diff -ruN pytsp/pytruespeech.c pytsp.fixed/pytruespeech.c --- pytsp/pytruespeech.c 2005-04-09 15:35:43.000000000 -0700 +++ pytsp.fixed/pytruespeech.c 2005-04-09 21:26:06.000000000 -0700 @@ -642,25 +642,24 @@ recording_driver=1; if (recorded != NULL) { - if (strlen(recorded)>=4096) { + // if (strlen(recorded)>=4096) { ofile=fopen(infile, "wb"); if (ofile) { - owritten=fwrite(recorded, 1, strlen(recorded), ofile); + //owritten=fwrite(recorded, 1, strlen(recorded), ofile); + owritten=fwrite(recorded, 1, ilen, ofile); fflush(ofile); fclose(ofile); - if (owritten==strlen(recorded)) { + //if (owritten==strlen(recorded)) { + if (owritten==ilen){ if (convertfile(infile, outfile, 8000, 16,1, 1)) { return outfile;} - } + } - } - - } - - } + } + // } + free(recorded); + } return ""; } - -