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 May 07, 2018 5:55 am

for my in-house product of RFID card attendance system in the office. I received a data from my server.
I just want to do is when a valid card is scanned by an employee,
I want to put a "welcome (name of employee )to atoz family" msg.

there is "TALKIE" library, but this library only works for Arduino. so I have to design library for my board.
can anyone help me with this???
or can anyone suggest a better way to accomplish my task???
I don't want to use any other voice module now(like speakjet ic and others).
is there any way to do like "text to speech" on esp32 board??

there is two library TALKIE.H and TTS.H. they both work fine with arduino.

any advice is appreciated.
here is code of TTS and TALKI.H library

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

Code: Select all

// Talkie library
// Copyright 2011 Peter Knight
// This code is released under GPLv2 license.
//
// Welcome to the Talkie library examples.
//
// Talkie is a speech synthesiser that works from a fixed vocabulary.
//
// There are hundreds of words in the 'Vocabulary' examples.
//
// Sound is output on digital pin 3. It can drive headphones directly, or add a simple audio amplifier to drive a loudspeaker.
// 

#include "talkie.h"

Talkie voice;

uint8_t spDANGER[] PROGMEM = {0x2D, 0xBF, 0x21, 0x92, 0x59, 0xB4, 0x9F, 0xA2, 0x87, 0x10, 0x8E, 0xDC, 0x72, 0xAB, 0x5B, 0x9D, 0x62, 0xA6, 0x42, 0x9E, 0x9C, 0xB8, 0xB3, 0x95, 0x0D, 0xAF, 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xFF, 0x07};
uint8_t spIS[]     PROGMEM = {0xAD, 0xED, 0xD5, 0x58, 0xA4, 0x9E, 0xCE, 0x76, 0xF5, 0xDD, 0xAB, 0x29, 0xF5, 0xD2, 0xDD, 0xEF, 0x7E, 0x0C, 0xC3, 0xA9, 0x06, 0xFA, 0xD3, 0x32, 0x0F, 0x6E, 0x94, 0x22, 0x8F, 0xF3, 0x92, 0xF6, 0x05, 0x43, 0xCC, 0x74, 0x77, 0x3E, 0xC3, 0xF5, 0x95, 0x98, 0xA9, 0xBA, 0x8B, 0x8F, 0x00, 0x7E, 0x73, 0xE5, 0x00, 0x05, 0x28, 0xF0, 0xFF};
uint8_t spALERT[]  PROGMEM = {0xA5, 0xCF, 0xC6, 0xAB, 0x55, 0x5B, 0xAF, 0x39, 0xDA, 0xC9, 0x54, 0xDD, 0xBC, 0xC6, 0xC2, 0x3C, 0x27, 0x20, 0xCF, 0x1C, 0xD7, 0x30, 0xB0, 0x45, 0x16, 0x69, 0x1D, 0xC3, 0x11, 0xE4, 0x59, 0x8A, 0x7C, 0xB5, 0x9B, 0x8B, 0xD9, 0x30, 0xB7, 0xD3, 0x76, 0x19, 0x9A, 0x25, 0x59, 0x57, 0x59, 0xEC, 0x11, 0xAF, 0xE8, 0xD9, 0xF9, 0x2A, 0x8A, 0x1D, 0xF0, 0x75, 0x3F, 0x73, 0xAC, 0x87, 0x3B, 0xA2, 0x0B, 0xAA, 0x2B, 0xCF, 0xE4, 0x10, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0x80, 0x01, 0x66, 0x36, 0x33, 0xC0, 0xAB, 0xD5, 0x0A, 0x68, 0x25, 0x85, 0x02, 0xFF, 0x0F};

void setup() {
  voice.say(spDANGER);
  voice.say(spDANGER);
  voice.say(spRED);
  voice.say(spALERT);
  voice.say(spMOTOR);
  voice.say(spIS);
  voice.say(spON);
  voice.say(spFIRE);
}
void loop() {
}

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

Re: ESP32 and AUDIO(text to speech)

Postby bobolink » Thu May 10, 2018 9:29 pm

I posted a conversion in "Showcase" viewtopic.php?f=17&t=5670

The only file changed was Talkie.cpp
But the file is now not backward compatible with the other Arduino processors.
The ESP-32 can't work with everything in the interrupt handler so I split it up.
Set up the timer for 8KHz
The LPC-10 algorithm uses 25 msec frames or 200 samples at 8K sps (that they call the ISR_RATIO)
Uses the DAC instead of PWM
Otherwise, it just worked.

Who is online

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