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;
    }
    


  • @chriswr It works on the M5stickC :)

    Can you explain the line " out = new AudioOutputI2S(0, 1, 32);" ?
    What do the numbers 0, 1, 32 mean?
    Thank you.



  • I see some examples, like here :
    https://www.xtronical.com/i2sinternetradio/
    There is a line:
    // audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
    It seems to be another way, but you can choose the language.
    Could this work on the M5stickC with the SPK HAT?
    What do I put on DIN connection, Bit clock, and Left Right Clock?



  • @chriswr said in How could I make text to speech using the speaker?:

    ESP8266SAM *sam = new ESP8266SAM;
    sam->Say(out, "Can you hear me now?");
    delay(500);
    sam->Say(out, "I can't hear you!");
    delete sam;

    @ChrisWR will this work with ATOM Echo Smart Speaker Development Kit? https://m5stack.com/collections/m5-atom