Repository navigation
AudioSpeech pitch / rate problem #80
Description
Activity
PDM audio has(had?) a bug in the IDF where the clock rate they set the HW was too high, but I thought I accounted for that in
BackgroundAudio/src/ESP32PDMAudio.h
Lines 70 to 72 in 0218451
// TODO - There is some fixed off-by-ratio 1/1.25 in the PDM output clock vs. the PCM input data at IDF 5.5 freq *= 8; freq /= 10; As a sanity test, are you able to get the proper speeds output when running another example like BeepWAV modified for PDM?
Also, what exact version of
pioarduinoand IDF are you running?Hello !
Playing a mp3 works fine using PDM (the volume is very low, but pitch is fine).
I am using idf 4 (esp32c3). So i should tune freq to slow wpm rate ?V
The volume out from the PDM device is just a function of the HW itself. It's just throwing out fewer transitions than you'd expect. Use the
setGainmethod to amplify the raw digital data.IDF4 is very old. https://github.com/espressif/arduino-esp32 is on 5.5, and has been on 5.x for over a year. I'd recommend updating if you're really on that old a version (not just for this, but for all the other bug fixes they've been doing!).
That said, I'll give it a test later today on the 3.3.1 core (5.5+ IDF) and see if I can repro the problem. Since you see it only in eSpeak, that narrows things down a lot!
One other possibility is that the PDM HW for some reason doesn't support the lower sample rate eSpeak data. eSpeak generates at a fixed at 22khz, while most MP3s are running 44.1 or 48k. We'll see...
Reacted by vcchmYou can take a look at #81 i tried to fix it for IDF v5.5.1.250929 and I have tested it for my ESP32 S3, the pitch and speed is perfect.
The problem occurs because we are not taking the hardware clock rate into account. Which led the hardware to consume sample faster than they should.
We can instruct it to use a stable clock rate by letting I2S run as a DAC.- added a commit that references this issue
on Oct 14, 2025 #81 looks like a good change, but it wasn't the root problem here. I reproduced @vcchm 's failure on an ESP32C3 and tracked it down to the sample rate change being lost before startup. So the audio for speech is playes back at 2x the rate it is generated for, because the
setFrequency(22050)got lost. #82 fixes that.I still think #81 is a good change, since it removes the "magic numbers" I reversed out, though!
Reacted by vcchm- added a commit that references this issue
on Oct 14, 2025
First thanks for theis great piece of software.
I am using this with an ESP32C3, and the pitch / speech rate is much too fast to be understood.
Code I use is folloiwing and even reducing rate to the minimum it is still too fast
Any idea how I can slow this down ? I tried to look if I could downscale the speed but it is not obvious. I suppose the chip frequency (160 Mhz) is too high but I need ti keep a fast CPU...