Page 1 of 1

Esp32 and audio (text to speech)

Posted: Mon Sep 17, 2018 11:44 am
by rankit0092
Hello Geeks,

i have an RFID card Scanning System, I wanna include audio Output into this.

What I wanna do is whenever an RFID card is Scanned, I want AUDIO output WELCOME "ANKIT"
I don't wanna play any audio file like (.mp3, wav ,etc)

so what I'm after is "TEXT TO SPEECH CONVERSION" AND I WANNA PLAY THAT TEXT WRITTEN IN CODE.

there are two libraries TALKIE.H and TTS.H. they both work fine with Arduino.
here is the code

Code: Select all

#include <TTS.h>

// Media pins
#define ledPin 13       // digital pin 13                         

// Variables
char text [50];
boolean state=0;

TTS text2speech;  // speech output is digital pin 10

void setup() {
  //media
  pinMode(ledPin, OUTPUT);
}

//================================================================
// Main Loop
//================================================================
void loop(){
    state = !state;
    digitalWrite(ledPin, state);
    Test_Speech();
    delay(1000);          // delay a second
} 
//================================================================


void Test_Speech() {
 text2speech.setPitch(6); //higher values = lower voice pitch
 strcpy(text, "Hello  master! How are you doin?");
 text2speech.say(text);
 delay(500);
 text2speech.setPitch(1); //lower values = higher voice pitch
 strcpy(text, "I am fine, thankyou.");
 text2speech.say(text);
}

Can i achieve this ON ESP32 ??
I don't wanna play any audio file.
is there any way to achieve this using i2s protocol?
any guidance is appreciated..
THANKS..

Re: Esp32 and audio (text to speech)

Posted: Mon Sep 17, 2018 2:11 pm
by chromebin
I haven't played audio yet, but it is certainly possible to output the audio via I2S. You might get started with the I2S example under Peripherals (https://github.com/espressif/esp-idf/tr ... herals/i2s).

I looked at the quality of the sound generated, http://webbot.org.uk/iPoint/45.page has 3 samples. I found the quality lacking, this will probably only suit simple feedback like YES, NO, HELLO.

Something reasonably pleasant like https://github.com/mozilla/TTS might also fit an ESP32.

Re: Esp32 and audio (text to speech)

Posted: Mon Sep 17, 2018 2:29 pm
by Vader_Mester
A better approach would be to get a sample lybrary in a .wav formats, convert it down to 8kHz sample rate PCM (10bit or 8bit for speech is enough), and store every sample as a binary array in a header file, with every character having it's own array.
This is the way people store character font info for displays.

Therefore you have easy time playing back strings. The I2S or DAC perfierial will have easy time outputting sound data or analog sound.

Re: Esp32 and audio (text to speech)

Posted: Mon Sep 17, 2018 4:31 pm
by Deouss

Re: Esp32 and audio (text to speech)

Posted: Mon Sep 17, 2018 5:40 pm
by bobolink
If talkie for Arduino works for you you can try
https://github.com/bobh/ESP32Talkie
Output is on a DAC pin.

Re: Esp32 and audio (text to speech)

Posted: Sat Sep 05, 2020 9:35 pm
by artium
Here is a port of Flite to ESP-IDF I made: https://github.com/alkhimey/esp32-flite

Here is a video of it in action: https://www.youtube.com/watch?v=PcJnTQw0B4I