ESP8266Audio
ESP8266Audio copied to clipboard
AudioGeneratorTalkie() playing too fast on ESP32
Using the example “ESP8266Audio/TalkingClockI2S” with an M5StickC (or M5StickCplus) and a speaker (M5StickC SPK HAT PAM8303) on GPIO26, and modifying the code as follows:
out = new AudioOutputI2S(0,1); // Output to ESP32-Built-In-DAC
out->SetPinout(16,26,17); // wclk=26 // Set DAC-Output to GPIO26 // GPIO16+17 are spare pins
out->SetOutputModeMono(true); // this does not seem to make any difference to below issue
out->SetGain(1.5);
[These units often also require “#include <M5StickC.h>” / “#include <M5StickCPlus.h>” and “M5.begin();”]
The above works fine for the “ESP8266Audio/WebRadio” example, and also for the “ESP8266SAM/Speak” example (although the latter only compiles on the M5StickCplus), BUT when used with the “TalkingClockI2S” the “talkie->say(..” speech is far too fast.
I note that “https://arduino.stackexchange.com/questions/69106/esp32-playing-wav-sounds-distorted-or-too-fast-but-not-all-wavs” talks about setting “_format = I2S_CHANNEL_FMT_ONLY_LEFT” (in AudioOutputI2S.cpp), but (a) this slows the talkie-speech a bit, but not sufficiently, and (b) this change causes the “WebRadio” and also “ESP8266SAM/Speak” to play too slowly.
[Note I am using "https://github.com/earlephilhower/ESP8266Audio" as at 19May23, and "https://github.com/espressif/arduino-esp32" as at 16Jan23, and ArduinoIDE v1.8.19, with Board=M5Stick-C with all settings default.]
[PS. if you want to use Talkie using the ESP32’s inbuilt DAC (GPIO25 or GPIO26) before this above issue is resolved, the Talkie repository at "https://github.com/bobh/ESP32Talkie" works (as at May2023). By default it uses GPIO25, and to use GPIO26 you need to edit “Talkie.cpp” in bobh's above code and change:
dacWrite(25, nextPwm);
to
dacWrite(26, nextPwm);
]