How could I make text to speech using the speaker?



  • I have M5stickC with speaker hat. I'm wondering if it's possible to perform text to speech routines in order to allow the speaker to speak a string.



  • This works on the M5stack, for the stickC I cannot test tho..

    #include <M5Stack.h>
    #include <M5StackUpdater.h>
    #include <Arduino.h>
    #include <ESP8266SAM.h>  //https://github.com/earlephilhower/ESP8266SAM
    #include <AudioOutputI2S.h>  //https://github.com/earlephilhower/ESP8266Audio
    
    AudioOutputI2S *out = NULL;
    
    void setup()
    {
      M5.begin();
      Wire.begin();
      if(digitalRead(BUTTON_A_PIN) == 0){
        Serial.println("Will load menu binary");
        updateFromFS(SD);
        ESP.restart();
      }  
      out = new AudioOutputI2S(0, 1, 32);
      out->begin();
    }
    
    void loop()
    {
      ESP8266SAM *sam = new ESP8266SAM;
      sam->Say(out, "Can you hear me now?");
      delay(500);
      sam->Say(out, "I can't hear you!");
      delete sam;
    }
    


  • Try this for the M5stickC could work, ...

    #include <M5StickC.h>
    #include <Arduino.h>
    #include <ESP8266SAM.h>  //https://github.com/earlephilhower/ESP8266SAM
    #include <AudioOutputI2S.h>  //https://github.com/earlephilhower/ESP8266Audio
    
    AudioOutputI2S *out = NULL;
    
    void setup()
    { 
      out = new AudioOutputI2S(0, 1, 32);
      out->begin();
    }
    
    void loop()
    {
      ESP8266SAM *sam = new ESP8266SAM;
      sam->Say(out, "Can you hear me now?");
      delay(500);
      sam->Say(out, "I can't hear you!");
      delete sam;
    }