Build a Text to Speech Converter using HTML, CSS & Javascript Last Updated : 28 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report A text-to-speech converter is an application that is used to convert the text content entered by the user into speech with a click of a button. A text-to-speech converter should have a text area at the top so that the user can enter a long text to be converted into speech, followed by a button that converts the entered text into speech and plays the sound on click to it. Here, we will build a fully responsive text-to-speech converter using HTML, CSS, and JavaScript.Project Previewtext to speechStep-by-Step guide to build a Text to Speech ConvertorCreate a folder with the project name and create the required HTML, CSS, and JavaScript files as shown in the project structure.Now, use the HTML tags like textarea, button, div, head, body etc. to define the structure of the website.Add the styles to the HTML tags used to define the structure by selecting them with the help of given IDs and Classes.Utilise the speechSynthesis API of the global window object and the SpeechSynthesisUtterance to create a utteraance of the entered text.Next, use the speak() method of the speechSynthesis API to speak or play the created utterance as a speech.Handle the errors efficiently if user have not provided any text to convert.Example: The below example will help you to understand the process of creating an text-to-speech converter using HTML, CSS, and JavaScript index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Text to Speech Converter</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div class="app-container"> <div class="headings-container"> <h1>Text to Speech Converter</h1> <h3>Enter Text and Convert into Speech</h3> </div> <div class="interaction-container"> <textarea id="textToConvert" placeholder="Enter text to convert into speech..." id="" cols="35" rows="10" class="text-control"></textarea> <p class="error-para"></p> <button class="btn" id="convertBtn"> Play Converted Sound </button> </div> </div> </div> <script src="script.js"></script> </body> </html> style.css @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap'); body { padding: 0; margin: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; } .container { height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; background-image: linear-gradient(90deg, #161578, #b81055); } .app-container { display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; color: #fff; } .headings-container { padding: 0 1rem; } .interaction-container { display: flex; align-items: normal; justify-content: center; flex-direction: column; text-align: center; padding: 0 1rem; } .text-control { padding: 0.5rem; margin: 2rem 0; background-color: #3f464a52; color: #fff; border: 1px solid #fff; border-radius: 10px; } .text-control:focus-visible { outline: none; } .error-para { color: red; } .btn { padding: 0.8rem; background-image: linear-gradient(90deg, #F4244C, #F57D4E); border: 1px solid transparent; border-radius: 10px; color: #fff; cursor: pointer; transition: all 0.25s; } .btn:hover { padding: 1rem; } index.js const text = document.getElementById("textToConvert"); const convertBtn = document.getElementById("convertBtn"); convertBtn.addEventListener('click', function () { const speechSynth = window.speechSynthesis; const enteredText = text.value; const error = document.querySelector('.error-para'); if (!speechSynth.speaking && !enteredText.trim().length) { error.textContent = `Nothing to Convert! Enter text in the text area.` } if (!speechSynth.speaking && enteredText.trim().length) { error.textContent = ""; const newUtter = new SpeechSynthesisUtterance(enteredText); speechSynth.speak(newUtter); convertBtn.textContent = "Sound is Playing..." } setTimeout(() => { convertBtn.textContent = "Play Converted Sound" }, 5000); }); OutputFinal OutputNote: You will not able to hear the voice as it is an gif so kindly run this project locally on any Online IDE(Replit, etc.) Comment More infoAdvertise with us Next Article Build a Text to Speech Converter using HTML, CSS & Javascript A abhish8rzd Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Projects Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w 8 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net 15+ min read Web Development Technologies Web development refers to building, creating, and maintaining websites. It includes aspects such as web design, web publishing, web programming, and database management. It is the creation of an application that works over the internet, i.e., websites.To better understand the foundation of web devel 7 min read CSS Tutorial CSS stands for Cascading Style Sheets. It is a stylesheet language used to style and enhance website presentation. CSS is one of the three main components of a webpage, along with HTML and JavaScript.HTML adds Structure to a web page.JavaScript adds logic to it and CSS makes it visually appealing or 7 min read Like