--- festival/speech_tools/audio/linux_sound.cc.orig 2013-07-02 02:45:02.953142985 +0200 +++ festival/speech_tools/audio/linux_sound.cc 2013-07-02 02:48:05.249370165 +0200 @@ -544,7 +544,14 @@ /* Set sample rate near the disired rate */ real_rate = sps; - err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0); + /* For some reason, ALSA sometimes sets a rate way too high when using + * snd_pcm_hw_params_set_rate_near(), so try setting the exact rate first + * before falling back to a nearby one */ + err = snd_pcm_hw_params_set_rate(pcm_handle, hwparams, real_rate, 0); + if (err < 0) + { + err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0); + } if (err < 0) { snd_pcm_close(pcm_handle);