Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design an ESP32-based text-to-speech engine

By Nikhil Agnihotri February 19, 2025

Text-to-speech (TTS) engines are widely used in assistive technology, communication systems, and automation in various industries. They’re essential for individuals with visual impairments or reading disabilities, enabling them to access written content audibly.

TTS also assists students with dyslexia, language learners, and individuals with learning difficulties. Virtual assistants like Siri, Alexa, and Google Assistant also use it to respond to user requests, while GPS devices and apps provide spoken navigation. Additionally, TTS is used in audiobooks, podcasts, and video games for voiceovers and narration.

In this project, we’ll build a TTS engine using an ESP32. The system will read a number the user enters on a webpage hosted by the ESP32. The ESP32 will then read the number aloud through a connected speaker.

Components

  1. ESP32 x1
  2. TDA2030A audio amplifier module x1
  3. 8Ohm speaker x1
  4. Connecting or DuPont wires

Circuit connections

To build this project, connect:

  • ESP32’s GPIO25 pin to the amplifier module’s Audio In + signal
  • The ground (GND) to the amplifier module’s Audio In – signal
  • The amplifier modules’ VCC and GND pins to ESP32’s 3V3 out and GND pins, respectively

Next, attach a 4Ω/8Ω speaker to the amplifier module’s speaker output connector. Finally, use a MicroUSB cable to connect ESP32 to upload the sketch, and power the board using a USB.

The circuit diagram for the device is as follows…

Arduino sketch

Now, connect ESP32 with your computer. Write and upload the following sketch on Arduino IDE.

How it works

ESP32 is programmed as a web server that hosts a webpage where users can input a number. It receives the number over the Internet and converts it to speech using the Talkie library. The generated speech is then played through a speaker connected to ESP32.

The code

For this project, you’ll need the Talkie library. Install the latest version of the Talkie library from the Library Manager in the Arduino IDE.

To summarize, the code creates a simple web server that performs text-to-speech (TTS) for numbers. It uses an ESP32 microcontroller, the Talkie library for speech synthesis, and a web interface for input.

This section includes the required libraries for the WiFi, including the Talkie library, and web server functionality. It also declares variables for WiFi credentials, the web server object, and the htmlResponse buffer.

It also defines the voice object of the Talkie class, which will be used to play the speech samples. The spZERO to spTHOUSAND, and other sp… arrays hold the audio data for each word, stored in program memory (flash) using the PROGMEM keyword to conserve valuable RAM.

This user-defined handleRoot() function serves the HTML page to the client. The HTML includes a text input field (msg) for the user to enter a number and a “Speak” button. JavaScript code is embedded using “jQuery” to handle the button click.

When the button is clicked, it retrieves the number from the input field and sends a GET request to the /speak endpoint on ESP32’s web server.

The user-defined textToSpeech() function is called when the server receives a request at the /speak endpoint. It retrieves the number from the request’s query parameter (Number), converts it to an integer, and then calls the speakOutNumber() function to handle the actual speech synthesis.

This user-defined speakOutNumber() function covers the core logic of the TTS. It recursively breaks down the number into thousands, hundreds, tens, and units, using the Talkie library’s say() function to play the corresponding speech samples. It also handles negative numbers, zero, and numbers up to 999,999.

The logic is a bit complex due to the way English language expresses numbers (e.g., “eleven” instead of “ten one”). So, it uses switch statements and if conditions to handle these special cases.

The setup() function initializes ESP32. It sets up the serial communication, connects to the WiFi network, and starts the web server. It also sets pin 25 high, at least initially, which is likely related to the Talkie library’s hardware setup.

The loop() function continuously listens for incoming client requests and processes them using the web server object.

Results

Video

You may also like:


  • The top IoT projects for enhancing everyday life

  • How ESP32 boards can communicate without a router or the…

  • What is ESP-NOW?

  • How to build a facial recognition system using ESP32-CAM

  • How to build a sign-to-speech converter

  • How to manage data on ESP32 for IoT projects

Filed Under: Electronic Projects
Tagged With: communication, language, speech, techarticle, text-to-speech, texttospeech, tts
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • High Side current sensing
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator
  • What Are the Main Types of Current Sensors?
  • problem connecting to my xilinx device VIA global IP

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe