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
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()
This is a output of project:
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)
Good tutorial, I would like to more about Tkinter.