I have a ESP32-S3 Reverse TFT Feather, a 3 Watt 8 Ohm Mini Speaker, and a MAX98357 Audio Power Amplifier
I am using this library GitHub - schreibfaul1/ESP32-audioI2S: Play mp3 files from SD via I2S
The audio can briefly sound good, but then the audio can become very distorted, almost robotic. Also the volume seems to fluctuate as well.
I'm also using the libraries text to speech function
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "my_ssid";
const char* password = "my_pwd";
#include <ESPAsyncWebServer.h>
AsyncWebServer server(80);
#include "Arduino.h"
#include "Audio.h"
#define I2S_DOUT 37
#define I2S_BCLK 38
#define I2S_LRC 39
Audio audio;
class Button {
public:
int numberpin;bool ispressed = false;
Button (int pin){numberpin = pin;}
virtual void onPressDown(){} virtual void onPressUp(){}
void listen()
{
int buttonState = digitalRead(numberpin);
if (buttonState == 1){if (!ispressed){onPressDown();ispressed=true;}}
else{if (ispressed){onPressUp();ispressed=false;}}
}
};
class ButtonOne : public Button {
public:
ButtonOne(int pin) : Button(pin) {}
/*add custom method*/
void onPressUp( ) override{
audio.connecttospeech("Mr and Mrs Dursley of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much","en");
delay(100);
}
};
ButtonOne buttonOne(1);
void setup() {
Serial.begin(115200);
pinMode(1, INPUT_PULLDOWN);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // 0 <> 21
WiFi.begin(ssid, password);
// Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
// Serial.print(".");
}
}
void loop() {
audio.loop();
buttonOne.listen();
}