Esp32 and audio (text to speech)

rankit0092
Posts: 16
Joined: Tue Jan 23, 2018 5:31 am

Esp32 and audio (text to speech)

Postby rankit0092 » Mon Sep 17, 2018 11:44 am

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..

chromebin
Posts: 77
Joined: Wed Feb 07, 2018 3:53 pm

Re: Esp32 and audio (text to speech)

Postby chromebin » Mon Sep 17, 2018 2:11 pm

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.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Esp32 and audio (text to speech)

Postby Vader_Mester » Mon Sep 17, 2018 2:29 pm

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.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}


bobolink
Posts: 98
Joined: Mon Feb 26, 2018 4:17 pm

Re: Esp32 and audio (text to speech)

Postby bobolink » Mon Sep 17, 2018 5:40 pm

If talkie for Arduino works for you you can try
https://github.com/bobh/ESP32Talkie
Output is on a DAC pin.

artium
Posts: 2
Joined: Sat Jul 20, 2019 8:43 am

Re: Esp32 and audio (text to speech)

Postby artium » Sat Sep 05, 2020 9:35 pm

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

Who is online

Users browsing this forum: Baidu [Spider] and 120 guests