Prerequisite: Introduction to Tkinter
Tkinter is the standard GUI library for Python. Python when combined with tkinter provides a fast and easy way to create GUI applications.By this library we can make a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority is to build something that’s functional and cross-platform quickly.
To create a tkinter application:
- Importing the module – tkinter
- Create the main window (container)
- Add any number of widgets to the main window
- Apply the event Trigger on the widgets.
Now, Let’s create a GUI based Text to speech convertor application which convert text into speech.
There are lots of library in python one of them is gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate’s text-to-speech API.
To install gTTS simply go to your terminal and type:
pip install gTTS
Below is the implementation :
Python3
# importing required module from tkinter import *from gtts import gTTS # this module helps to # play the converted audio import os # create tkinter window root = Tk() # styling the frame which helps to # make our background stylish frame1 = Frame(root, bg = "lightPink", height = "150") # plcae the widget in gui window frame1.pack(fill = X) frame2 = Frame(root, bg = "lightgreen", height = "750") frame2.pack(fill=X) # styling the label which show the text # in our tkinter window label = Label(frame1, text = "Text to Speech", font = "bold, 30", bg = "lightpink") label.place(x = 180, y = 70) # entry is used to enter the text entry = Entry(frame2, width = 45, bd = 4, font = 14) entry.place(x = 130, y = 52) entry.insert(0, "") # define a function which can # get text and convert into audio def play(): # Language in which you want to convert language = "en" # Passing the text and language, # here we have slow=False. Which tells # the module that the converted audio should # have a high speed myobj = gTTS(text = entry.get(), lang = language, slow = False) # give the name as you want to # save the audio myobj.save("convert.wav") os.system("convert.wav") # cereate a button which holds # our play function using command = play btn = Button(frame2, text = "SUBMIT", width = "15", pady = 10, font = "bold, 15", command = play, bg='yellow') btn.place(x = 250, y = 130) # give a title root.title("text_to_speech_convertor") # we can not change the size # if you want you can change root.geometry("650x550+350+200") # start the gui root.mainloop() |
Output:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python - UwU text convertor GUI using Tkinter
- Python - English (Latin) to Hindi (Devanagiri) text convertor GUI using Tkinter
- Python: Convert Speech to text and text to Speech
- Python | Real time currency convertor using Tkinter
- Speech Recognition in Python using Google Speech API
- Python - SpongeBob Mocking Text Generator GUI using Tkinter
- UwU text convertor in Python
- Python | Simple GUI calculator using Tkinter
- Python | Distance-time GUI calculator using Tkinter
- Python - Compound Interest GUI Calculator using Tkinter
- Python | Create a GUI Marksheet using Tkinter
- Python: Weight Conversion GUI using Tkinter
- Python | ToDo GUI Application using Tkinter
- Python | GUI Calendar using Tkinter
- Sentiment Detector GUI using Tkinter - Python
- Python - Morse Code Translator GUI using Tkinter
- Create First GUI Application using Python-Tkinter
- Python - Spell Corrector GUI using Tkinter
- GST Rate Finder GUI using Python-Tkinter
- Create Copy-Move GUI using Tkinter in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

