/* * WAV TO TEXT */ #include #include #include #include #include "support.h" /* --------------------------------------------------------------- */ /* * at this time, 'format' must be 0 */ int convert_wav_to_text(char *infname, int format) { SNDFILE * sndf; SF_INFO sfinfo; int foo, lu; short * samples; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' )\n", __func__, infname); #endif if (format) { fprintf(stderr, "in %s, format must be 0 and was %d\n", __func__, format); exit(1); } memset(&sfinfo, 0, sizeof(sfinfo)); /* be clean */ sndf = sf_open(infname, SFM_READ, &sfinfo); if (sndf==NULL) { /*catch the snfile errmsg here XXX */ fprintf(stderr, "error sf_opening %s\n", infname); exit(1); } foo = display_sf_info(&sfinfo, infname); if (foo) { fprintf(stderr, "%s: corrupted sf_info ?\n", __func__); abort(); } if (2 != sfinfo.channels) { fprintf(stderr, "/!\\ %s is not a stereo file, exiting...\n", infname); return -2; } /* get memory for bufferins read from sound file */ if ( NULL == (samples = malloc(BUFFER_SIZE*sizeof(short))) ) { perror("\n no memory in converter"); abort(); } while ( (lu=sf_read_short(sndf, samples, BUFFER_SIZE)) > 0 ) { for (foo=0; footext converter\n", foo); return 0; } /* --------------------------------------------------------------- */