0% found this document useful (0 votes)
366 views

ESP32 Based Webserver For Text To Speech (TTS) Conversion

- ESP32 based Webserver for Text to Speech (TTS) Conversion - The ESP32 converts any text entered on a webpage into speech that is output through a connected speaker - An LM386 amplifier circuit is used to amplify the audio signal from the ESP32 to drive the speaker clearly and loudly - The ESP32 uses the Talkie library to convert numbers entered as text into their spoken equivalents, which are stored as hex code phonemes

Uploaded by

CahyaDsn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
366 views

ESP32 Based Webserver For Text To Speech (TTS) Conversion

- ESP32 based Webserver for Text to Speech (TTS) Conversion - The ESP32 converts any text entered on a webpage into speech that is output through a connected speaker - An LM386 amplifier circuit is used to amplify the audio signal from the ESP32 to drive the speaker clearly and loudly - The ESP32 uses the Talkie library to convert numbers entered as text into their spoken equivalents, which are stored as hex code phonemes

Uploaded by

CahyaDsn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

 (https://www.facebook.com/IoT-Design-Pro-284393472235331/)  (https://twitter.

com/IoTDesignPro1) 
(https://www.pinterest.com/iotdesignpro)

ESP32 09 Jul, 2019 / 0 Comments

ESP32 based Webserver for Text to Speech (TTS) Conversion

Shares

Text to speech (TTS) has been used in many applications like voice assistants, announcements, ATMs etc. It is also used to help children
in learning speaking and blind people in communication. Today we will use ESP32 to build a TTS (Text to Speech) engine which can
convert any number into speech. The number will be entered from a Webpage and speech will be generated from ESP32 attached
speaker. Also check other ESP32 based IoT projects (https://iotdesignpro.com/esp32-projects).
 

Required Components
1. ESP32 Microcontroller
2. A speaker
3. An Ampli er Circuit
4. Regulated Power Supply
5. Connecting Wires

Circuit Diagram
We can drive the speakers directly by connecting it to ESP32 but the sound will have lot of noise. So here an ampli er circuit is used to get
a clear and loud sound. Here an LM386 based ampli er circuit is used, circuit diagram for the same is given below:
Shares

 
This circuit diagram has been taken from this link LM386 Based Audio Ampli er Circuit (https://circuitdigest.com/electronic-circuits/lm386-
audio-ampli er-circuit), learn more about the functioning of this ampli er by going through the link.
 

Connecting Speaker to ESP32


After making the above ampli er circuit, connect the ESP32 to the ampli er circuit as shown below. Connect the digital pin 25 of ESP32 to
10K resistor and ground of ESP32 to the ground of ampli er circuit.
Shares

Programming ESP32 for Text To Speech


The programming part to convert text into speech using ESP32 is simple. Complete code with Demo video is given at the end of this
tutorial.
First we have to install a library called as Talkie, it can be downloaded from here (https://github.com/bobh/ESP32Talkie). And then add it to
Arduino IDE by going to Sketch->Include Library->Add .ZIP Library.
Then start writing the code by including all the required libraries. Wi .h, Wi Client.h are used to create a client to connect to ISP using Wi-Fi.
WebServer.h is used to create the web server and ESPmDNS.h is used for local mDNS request.

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Talkie.h>

 
Next de ne an object voice for Talkie.

Talkie voice;

 
In the next portion, we are de ning the numbers (i.e one, two, three etc.). You can also add more words/phonemes by recording the
sound for each one and converting them into hex code. There are various softwares available for converting them into hex like Binary
Viewer (https://www.proxoft.com/downloads/pxBinaryViewerSetup.exe).

const uint8_t spZERO[] PROGMEM = {0x69, 0xFB, 0x59, 0xDD, 0x51, 0xD5, 0xD7, 0xB5, 0x6F, 0x0A, 0x78, 0xC0, 0x52, 0x01, 0x0
const uint8_t spONE[] PROGMEM = {0x66, 0x4E, 0xA8, 0x7A, 0x8D, 0xED, 0xC4, 0xB5, 0xCD, 0x89, 0xD4, 0xBC, 0xA2, 0xDB, 0xD
…..
……….

 
Now de ne a function which can speak out any number between -999,999 and 999,999. This function can be found in the Talkie library.
This function uses simple logics. Firstly it checks if the number is negative and if it is negative then it adds a “minus” before saying the
word. If it is zero then it speaks zero.
Then it checks if the number is greater than or equal to thousand so that it can attach “thousands” before saying it. Then it checks
remainder by dividing the number by 1000 to tell the digits after thousand. The same logic is used for hundreds or three digit number.

void sayNumber(long n) {
if (n<0) {
voice.say(spMINUS);
sayNumber(-n);
} else if (n==0) {
Shares voice.say(spZERO);
} else {
if (n>=1000) {
int thousands = n / 1000;
sayNumber(thousands);
voice.say(spTHOUSAND);
n %= 1000;
if ((n > 0) && (n<100)) voice.say(spAND);
}
if (n>=100) {
int hundreds = n / 100;
sayNumber(hundreds);
voice.say(spHUNDRED);
n %= 100;
if (n > 0) voice.say(spAND);
}
………….
…………….

 
Now set up the Wi-Fi. Enter replace the name and password of your Wi-Fi in the code. Because we are using HTTP protocol so we enter 80
in the server() function. Because 80 is the default port number for HTTP.

const char* ssid = "CircuitLoop";


const char* password = "xxxx";
WebServer server ( 80 );

 
Now de ne an array htmlResponse to get the input from webpage.

char htmlResponse[3000];

 
Next de ne a function handleRoot() to create an html page. The snprintf() function is used to produce the html page coded in it. Now start
coding the html page by passing the htmlResponse array to it with its size. Firstly give the heading named as “Text To Speech”. Then create
the textbox and button in HTML.
Next write the JavaScript code. Firstly de ne a variable Number for the input we are getting and then assign the value entered in text box
to the Number. At the end send the webpage to server.
void handleRoot() {
snprintf ( htmlResponse, 3000,
"<!DOCTYPE html>\
<html lang=\"en\">\
<head>\
<meta charset=\"utf-8\">\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\
</head>\
<body>\
<h1>Text To Speech</h1>\
<input type='text' name='msg' id='msg' size=7 autofocus> Number \
Shares
<div>\
<br><button id=\"speak_button\">Speak</button>\
</div>\
<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\
<script>\
var Number;\
$('#speak_button').click(function(e){\
e.preventDefault();\
Number = $('#msg').val();\
$.get('/save?Number=' + Number , function(data){\
console.log(data);\
});\
});\
</script>\
</body>\
</html>");
server.send ( 200, "text/html", htmlResponse );
}

 
In the next portion de ne a function handleSave(). Here we convert the string into integer, because the input we are getting is a string and
to speak it out we have to use it as an integer.

void handleSave() {
if (server.arg("Number")!= "")
{
Serial.println("Message: " + server.arg("Number"));
String serverData = String(server.arg("Number"));
int finalServer = serverData.toInt();
sayNumber(finalServer);
delay(2000);
}
}

 
Now in setup() function, rstly, we de ne the digital pin 25 as output and keep it high. Then initialize the Wi-Fi using Wi .begin() function
and print some status messages. Then in next lines we start the server by calling the handleRoot() function and get the input from web
page by calling the handleSave() function and nally print the message “HTTP server started”.
void setup() {
pinMode(25, OUTPUT);
digitalWrite(25, HIGH);
delay(10);
// Start serial
Serial.begin(115200);
delay(10);

// Connecting to a WiFi network


Serial.println();
Serial.println();
Shares
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

server.on ( "/", handleRoot );


server.on ("/save", handleSave);

server.begin();
Serial.println ( "HTTP server started" );
}

Text to Speech conversion using ESP32 via webpage


Finally upload the code into ESP32 using Arduino IDE and run it. Open the serial monitor Copy the IP address displayed in the serial
monitor as shown in below image.

 
The webpage will look like this:
Shares

 
Enter any number and hit Speak button and the system will speak the number.
So this is how ESP32 can be used to convert text into speech and this webpage can be opened from anywhere in the world by forwarding
the port in Wi-Fi router.

Code
// Libraries
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Talkie.h>
Talkie voice;
const uint8_t spZERO[]     PROGMEM = {0x69, 0xFB, 0x59, 0xDD, 0x51, 0xD5, 0xD7, 0xB5, 0x6F, 0x0A, 0x78, 0xC0, 0x52, 0x01, 0x0F, 0x50, 0xAC,
0xF6, 0xA8, 0x16, 0x15, 0xF2, 0x7B, 0xEA, 0x19, 0x47, 0xD0, 0x64, 0xEB, 0xAD, 0x76, 0xB5, 0xEB, 0xD1, 0x96, 0x24, 0x6E, 0x62, 0x6D, 0x5B, 0x1F,
0x0A, 0xA7, 0xB9, 0xC5, 0xAB, 0xFD, 0x1A, 0x62, 0xF0, 0xF0, 0xE2, 0x6C, 0x73, 0x1C, 0x73, 0x52, 0x1D, 0x19, 0x94, 0x6F, 0xCE, 0x7D, 0xED, 0x6B,
0xD9, 0x82, 0xDC, 0x48, 0xC7, 0x2E, 0x71, 0x8B, 0xBB, 0xDF, 0xFF, 0x1F};
const uint8_t spONE[]      PROGMEM = {0x66, 0x4E, 0xA8, 0x7A, 0x8D, 0xED, 0xC4, 0xB5, 0xCD, 0x89, 0xD4, 0xBC, 0xA2, 0xDB, 0xD1, 0x27, 0xBE,
0x33, 0x4C, 0xD9, 0x4F, 0x9B, 0x4D, 0x57, 0x8A, 0x76, 0xBE, 0xF5, 0xA9, 0xAA, 0x2E, 0x4F, 0xD5, 0xCD, 0xB7, 0xD9, 0x43, 0x5B, 0x87, 0x13, 0x4C,
0x0D, 0xA7, 0x75, 0xAB, 0x7B, 0x3E, 0xE3, 0x19, 0x6F, 0x7F, 0xA7, 0xA7, 0xF9, 0xD0, 0x30, 0x5B, 0x1D, 0x9E, 0x9A, 0x34, 0x44, 0xBC, 0xB6, 0x7D,
0xFE, 0x1F};
const uint8_t spTWO[]      PROGMEM = {0x06, 0xB8, 0x59, 0x34, 0x00, 0x27, 0xD6, 0x38, 0x60, 0x58, 0xD3, 0x91, 0x55, 0x2D, 0xAA, 0x65, 0x9D,
0x4F, 0xD1, 0xB8, 0x39, 0x17, 0x67, 0xBF, 0xC5, 0xAE, 0x5A, 0x1D, 0xB5, 0x7A, 0x06, 0xF6, 0xA9, 0x7D, 0x9D, 0xD2, 0x6C, 0x55, 0xA5, 0x26, 0x75,
0xC9, 0x9B, 0xDF, 0xFC, 0x6E, 0x0E, 0x63, 0x3A, 0x34, 0x70, 0xAF, 0x3E, 0xFF, 0x1F};
const uint8_t spTHREE[]    PROGMEM = {0x0C, 0xE8, 0x2E, 0x94, 0x01, 0x4D, 0xBA, 0x4A, 0x40, 0x03, 0x16, 0x68, 0x69, 0x36, 0x1C, 0xE9, 0xBA,
Shares
0xB8, 0xE5, 0x39, 0x70, 0x72, 0x84, 0xDB,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x74, 0x08, 0xE7, 0xCE, 0x77, 0x78, 0x06, 0x89, 0x32,
0x57, 0xD6, 0xF1, 0xF1, 0x8F, 0x7D, 0xFE, 0x1F};
const uint8_t spTHIR_[]    PROGMEM = {0x04, 0xA8, 0xBE, 0x5C, 0x00, 0xDD, 0xA5, 0x11, 0xA0, 0xFA, 0x72, 0x02, 0x74, 0x97, 0xC6, 0x01, 0x09,
0x9C, 0xA6, 0xAB, 0x30, 0x0D, 0xCE, 0x7A, 0xEA, 0x6A, 0x4A, 0x39, 0x35, 0xFB, 0xAA, 0x8B, 0x1B, 0xC6, 0x76, 0xF7, 0xAB, 0x2E, 0x79, 0x19, 0xCA,
0xD5, 0xEF, 0xCA, 0x57, 0x08, 0x14, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0xC0, 0xFF, 0x03};
const uint8_t spFIF_[]     PROGMEM = {0x08, 0x98, 0x31, 0x93, 0x02, 0x1C, 0xE0, 0x80, 0x07, 0x5A, 0xD6, 0x1C, 0x6B, 0x78, 0x2E, 0xBD, 0xE5, 0x2D,
0x4F, 0xDD, 0xAD, 0xAB, 0xAA, 0x6D, 0xC9, 0x23, 0x02, 0x56, 0x4C, 0x93, 0x00, 0x05, 0x10, 0x90, 0x89, 0x31, 0xFC, 0x3F};
const uint8_t sp_TEEN[]    PROGMEM = {0x09, 0x58, 0x2A, 0x25, 0x00, 0xCB, 0x9F, 0x95, 0x6C, 0x14, 0x21, 0x89, 0xA9, 0x78, 0xB3, 0x5B, 0xEC,
0xBA, 0xB5, 0x23, 0x13, 0x46, 0x97, 0x99, 0x3E, 0xD6, 0xB9, 0x2E, 0x79, 0xC9, 0x5B, 0xD8, 0x47, 0x41, 0x53, 0x1F, 0xC7, 0xE1, 0x9C, 0x85, 0x54,
0x22, 0xEC, 0xFA, 0xDB, 0xDD, 0x23, 0x93, 0x49, 0xB8, 0xE6, 0x78, 0xFF, 0x3F};
const uint8_t spTWENTY[]   PROGMEM = {0x0A, 0xE8, 0x4A, 0xCD, 0x01, 0xDB, 0xB9, 0x33, 0xC0, 0xA6, 0x54, 0x0C, 0xA4, 0x34, 0xD9, 0xF2, 0x0A,
0x6C, 0xBB, 0xB3, 0x53, 0x0E, 0x5D, 0xA6, 0x25, 0x9B, 0x6F, 0x75, 0xCA, 0x61, 0x52, 0xDC, 0x74, 0x49, 0xA9, 0x8A, 0xC4, 0x76, 0x4D, 0xD7, 0xB1,
0x76, 0xC0, 0x55, 0xA6, 0x65, 0xD8, 0x26, 0x99, 0x5C, 0x56, 0xAD, 0xB9, 0x25, 0x23, 0xD5, 0x7C, 0x32, 0x96, 0xE9, 0x9B, 0x20, 0x7D, 0xCB, 0x3C,
0xFA, 0x55, 0xAE, 0x99, 0x1A, 0x30, 0xFC, 0x4B, 0x3C, 0xFF, 0x1F};
const uint8_t spT[]        PROGMEM = {0x01, 0xD8, 0xB6, 0xDD, 0x01, 0x2F, 0xF4, 0x38, 0x60, 0xD5, 0xD1, 0x91, 0x4D, 0x97, 0x84, 0xE6, 0x4B, 0x4E,
0x36, 0xB2, 0x10, 0x67, 0xCD, 0x19, 0xD9, 0x2C, 0x01, 0x94, 0xF1, 0x78, 0x66, 0x33, 0xEB, 0x79, 0xAF, 0x7B, 0x57, 0x87, 0x36, 0xAF, 0x52, 0x08,
0x9E, 0x6B, 0xEA, 0x5A, 0xB7, 0x7A, 0x94, 0x73, 0x45, 0x47, 0xAC, 0x5A, 0x9C, 0xAF, 0xFF, 0x07};
const uint8_t spHUNDRED[]  PROGMEM = {0x04, 0xC8, 0x7E, 0x5C, 0x02, 0x0A, 0xA8, 0x62, 0x43, 0x03, 0xA7, 0xA8, 0x62, 0x43, 0x4B, 0x97, 0xDC,
0xF2, 0x14, 0xC5, 0xA7, 0x9B, 0x7A, 0xD3, 0x95, 0x37, 0xC3, 0x1E, 0x16, 0x4A, 0x66, 0x36, 0xF3, 0x5A, 0x89, 0x6E, 0xD4, 0x30, 0x55, 0xB5, 0x32,
0xB7, 0x31, 0xB5, 0xC1, 0x69, 0x2C, 0xE9, 0xF7, 0xBC, 0x96, 0x12, 0x39, 0xD4, 0xB5, 0xFD, 0xDA, 0x9B, 0x0F, 0xD1, 0x90, 0xEE, 0xF5, 0xE4, 0x17,
0x02, 0x45, 0x28, 0x77, 0x11, 0xD9, 0x40, 0x9E, 0x45, 0xDD, 0x2B, 0x33, 0x71, 0x7A, 0xBA, 0x0B, 0x13, 0x95, 0x2D, 0xF9, 0xF9, 0x7F};
const uint8_t spTHOUSAND[] PROGMEM = {0x0C, 0xE8, 0x2E, 0xD4, 0x02, 0x06, 0x98, 0xD2, 0x55, 0x03, 0x16, 0x68, 0x7D, 0x17, 0xE9, 0x6E, 0xBC,
0x65, 0x8C, 0x45, 0x6D, 0xA6, 0xE9, 0x96, 0xDD, 0xDE, 0xF6, 0xB6, 0xB7, 0x5E, 0x75, 0xD4, 0x93, 0xA5, 0x9C, 0x7B, 0x57, 0xB3, 0x6E, 0x7D, 0x12,
0x19, 0xAD, 0xDC, 0x29, 0x8D, 0x4F, 0x93, 0xB4, 0x87, 0xD2, 0xB6, 0xFC, 0xDD, 0xAC, 0x22, 0x56, 0x02, 0x70, 0x18, 0xCA, 0x18, 0x26, 0xB5, 0x90,
Shares
0xD4, 0xDE, 0x6B, 0x29, 0xDA, 0x2D, 0x25, 0x17, 0x8D, 0x79, 0x88, 0xD4, 0x48, 0x79, 0x5D, 0xF7, 0x74, 0x75, 0xA1, 0x94, 0xA9, 0xD1, 0xF2, 0xED,
0x9E, 0xAA, 0x51, 0xA6, 0xD4, 0x9E, 0x7F, 0xED, 0x6F, 0xFE, 0x2B, 0xD1, 0xC7, 0x3D, 0x89, 0xFA, 0xB7, 0x0D, 0x57, 0xD3, 0xB4, 0xF5, 0x37, 0x55,
0x37, 0x2E, 0xE6, 0xB2, 0xD7, 0x57, 0xFF, 0x0F};
const uint8_t spAND[]      PROGMEM = {0xA9, 0x6B, 0x21, 0xB9, 0x22, 0x66, 0x9F, 0xAE, 0xC7, 0xE1, 0x70, 0x7B, 0x72, 0xBB, 0x5B, 0xDF, 0xEA,
0x56, 0xBB, 0x5C, 0x65, 0xCB, 0x66, 0xC5, 0x3D, 0x67, 0xD7, 0xAB, 0x6D, 0x2E, 0x64, 0x30, 0x93, 0xEE, 0xB1, 0xCD, 0x3D, 0x92, 0xB9, 0x9A, 0xDA,
0xB2, 0x8E, 0x40, 0x12, 0x9A, 0x6A, 0xEB, 0x96, 0x8F, 0x78, 0x98, 0xB3, 0x2A, 0xB4, 0xD3, 0x48, 0xAA, 0x2F, 0x7D, 0xA7, 0x7B, 0xFB, 0x0C, 0x73,
0x71, 0x5C, 0xCE, 0x6E, 0x5C, 0x52, 0x6C, 0x73, 0x79, 0x9A, 0x13, 0x4B, 0x89, 0x45, 0xE9, 0x6E, 0x49, 0x42, 0xA9, 0x57, 0xFF, 0x3F};
const uint8_t spMINUS[]    PROGMEM = {0xE6, 0x28, 0xC4, 0xF8, 0x44, 0x9A, 0xFB, 0xCD, 0xAD, 0x8D, 0x2A, 0x4E, 0x4A, 0xBC, 0xB8, 0x8C, 0xB9,
0x8A, 0xA9, 0x48, 0xED, 0x72, 0x87, 0xD3, 0x74, 0x3B, 0x1A, 0xA9, 0x9D, 0x6F, 0xB3, 0xCA, 0x5E, 0x8C, 0xC3, 0x7B, 0xF2, 0xCE, 0x5A, 0x5E, 0x35,
0x66, 0x5A, 0x3A, 0xAE, 0x55, 0xEB, 0x9A, 0x57, 0x75, 0xA9, 0x29, 0x6B, 0xEE, 0xB6, 0xD5, 0x4D, 0x37, 0xEF, 0xB5, 0x5D, 0xC5, 0x95, 0x84, 0xE5,
0xA6, 0xFC, 0x30, 0xE0, 0x97, 0x0C, 0x0D, 0x58, 0x40, 0x03, 0x1C, 0xA0, 0xC0, 0xFF, 0x03};
/* Say any number between -999,999 and 999,999 */
void sayNumber(long n) {
  if (n<0) {
    voice.say(spMINUS);
    sayNumber(-n);
  } else if (n==0) {
    voice.say(spZERO);
  } else {
    if (n>=1000) {
      int thousands = n / 1000;
      sayNumber(thousands);
      voice.say(spTHOUSAND);
      n %= 1000;
      if ((n > 0) && (n<100)) voice.say(spAND);
  }
    if (n>=100) {
      int hundreds = n / 100;
      sayNumber(hundreds);
      voice.say(spHUNDRED);
      n %= 100;
      if (n > 0) voice.say(spAND);
  }
    if (n>19) {
      int tens = n / 10;
      switch (tens) {
        case 2: voice.say(spTWENTY); break;
        case 3: voice.say(spTHIR_); voice.say(spT); break;
        case 4: voice.say(spFOUR); voice.say(spT);  break;
        case 5: voice.say(spFIF_);  voice.say(spT); break;
        case 6: voice.say(spSIX);  voice.say(spT); break;
        case 7: voice.say(spSEVEN);  voice.say(spT); break;
        case 8: voice.say(spEIGHT);  voice.say(spT); break;
        case 9: voice.say(spNINE);  voice.say(spT); break;
   }
      n %= 10;
  }
    switch(n) {
      case 1: voice.say(spONE); break;
      case 2: voice.say(spTWO); break;
      case 3: voice.say(spTHREE); break;
      case 4: voice.say(spFOUR); break;
      case 5: voice.say(spFIVE); break;
      case 6: voice.say(spSIX); break;
      case 7: voice.say(spSEVEN); break;
      case 8: voice.say(spEIGHT); break;
      case 9: voice.say(spNINE); break;
      case 10: voice.say(spTEN); break;
      case 11: voice.say(spELEVEN); break;
Shares
      case 12: voice.say(spTWELVE); break;
      case 13: voice.say(spTHIR_); voice.say(sp_TEEN); break;
      case 14: voice.say(spFOUR); voice.say(sp_TEEN);break;
      case 15: voice.say(spFIF_); voice.say(sp_TEEN); break;
      case 16: voice.say(spSIX); voice.say(sp_TEEN); break;
      case 17: voice.say(spSEVEN); voice.say(sp_TEEN); break;
      case 18: voice.say(spEIGHT); voice.say(sp_TEEN); break;
      case 19: voice.say(spNINE); voice.say(sp_TEEN); break;
  }
 }
}
// WiFi network
const char* ssid     = "CircuitLoop";
const char* password = "circuitdigest101";
WebServer server ( 80 );
char htmlResponse[3000];
void handleRoot() {
  snprintf ( htmlResponse, 3000,
"<!DOCTYPE html>\
<html lang=\"en\">\
  <head>\
    <meta charset=\"utf-8\">\
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\
  </head>\
  <body>\
          <h1>Text To Speech</h1>\
          <input type='text' name='msg' id='msg' size=7 autofocus> Number \
          <div>\
          <br><button id=\"speak_button\">Speak</button>\
          </div>\
    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\    
    <script>\
      var Number;\
      $('#speak_button').click(function(e){\
        e.preventDefault();\
        Number = $('#msg').val();\       
        $.get('/save?Number=' + Number , function(data){\
          console.log(data);\
        });\
      });\      
    </script>\
  </body>\
</html>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy