DEV Community 👩‍💻👨‍💻

Cover image for Text to Speech app with python
Kaveh Sabouri
Kaveh Sabouri

Posted on

Text to Speech app with python

Hello everyone today we want make text to speech app with python.

for this project we must install gtts module.

Write this in your terminal for install it:

pip install gtts
Enter fullscreen mode Exit fullscreen mode

Code:

from tkinter import *
from tkinter import messagebox
from gtts import gTTS


window = Tk()
window.title("Text to Speech")
window.config(bg="#C9CBA3")
window.geometry("500x500")

def change():
    if entry.get() == "":
        messagebox.showerror("Error","No text to speak")
    else:
        messagebox.showinfo("Info","Please wait")
        speech = gTTS(text=entry.get())
        speech.save("speech.mp3")

label_welcome = Label(window,text="Text to speech",font=("Lalezar",40),fg="#E26D5C",bg="#C9CBA3")
label_welcome.pack()

entry = Entry(window)
entry.focus()
entry.place(x=130,y=220,width=250,height=30)


button_change = Button(window,text="Change",bg="#E26D5C",command=change,font=("",20))
button_change.place(x=195,y=400)

window.mainloop()

Enter fullscreen mode Exit fullscreen mode

This is a output of project:

Image description

This application has been tested on Mac, and its appearance may change in Windows or Linux.

Thank you for reading this post.

Top comments (1)

Collapse
 
udanielnogueira profile image
Daniel Nogueira

Good tutorial, I would like to more about Tkinter.

Let's Get Wacky


Use any Linode offering to create something unique or silly in the DEV x Linode Hackathon 2022 and win the Wacky Wildcard category

Join the Hackathon <-