This patch is part of a series of patches for speech-tools for Debian GNU/Linux, which primarily fix build errors with GCC 4.3 and newer. --- speech-tools-1.2.3.orig/speech_class/EST_WaveFile.cc +++ speech-tools-1.2.3/speech_class/EST_WaveFile.cc @@ -85,7 +85,10 @@ if (status == read_ok) { - wv.values().set_memory(data, 0, nsamp, nchan, TRUE); + short *data2 = new short[nsamp*nchan]; + memcpy(data2, data, nsamp*nchan*sizeof(short)); + wfree(data); + wv.values().set_memory(data2, 0, nsamp, nchan, TRUE); wv.set_sample_rate(srate); } @@ -312,6 +312,27 @@ return save_using(save_wave_ulaw, fp, localwv, stype, bo); } +EST_read_status EST_WaveFile::load_alaw(EST_TokenStream &ts, + EST_Wave &wv, + int rate, + EST_sample_type_t stype, int bo, int nchan, + int offset, int length) +{ + return load_using(load_wave_alaw, + ts, wv, rate, + stype, bo, nchan, + offset, length); +} + +EST_write_status EST_WaveFile::save_alaw(FILE *fp, + const EST_Wave &wv, + EST_sample_type_t stype, int bo) +{ + EST_Wave localwv = wv; + localwv.resample(8000); + return save_using(save_wave_alaw, fp, localwv, stype, bo); +} + static int parse_esps_r_option(EST_String arg, int &offset, int &length) { EST_String s, e; @@ -382,6 +403,11 @@ al.add_item("-itype","ulaw"); al.add_item("-f","8000"); } + if (al.present("-alaw")) + { + al.add_item("-itype","alaw"); + al.add_item("-f","8000"); + } if (al.present("-iswap")) al.add_item("-ibo","other"); @@ -417,6 +443,11 @@ sample_rate = 8000; sample_type = "mulaw"; } + if (file_type == "alaw") + { + sample_rate = 8000; + sample_type = "alaw"; + } if (al.present("-r")) // only load in part of waveform {