## import libraries

from tkinter import *
from gtts import gTTS
from playsound import playsound



################### Initialized window####################

root = Tk()
root.geometry('350x300')
root.resizable(0,0)
root.config(bg = 'light yellow')
root.title('DataFlair - TEXT_TO_SPEECH')


##heading
Label(root, text = 'HELIGA TEKST' , font='arial 20 bold' , bg ='white smoke').pack()
Label(root, text ='DataFlair' , font ='arial 15 bold', bg = 'blue').pack(side = BOTTOM)




#label
Label(root, text ='Sisesta Tekst', font ='arial 15 bold', bg ='white').place(x=20,y=60)


##text variable
Msg = StringVar()


#Entry
entry_field = Entry(root,textvariable =Msg, width ='50')
entry_field.place(x=20 , y=100)


###################define function##############################

def Tekst():
    Message = entry_field.get()
    speech = gTTS(text = Message, lang ='et', slow = True)
    speech.save('DataFlair.mp3')
    playsound('DataFlair.mp3')


def Exit():
    root.destroy()

def Reset():
    Msg.set("")

#Button
Button(root, text = "ESITA" , font = 'arial 15 bold', command = Tekst, bg = 'light blue', width =6).place(x=25, y=140)
Button(root,text = 'VÄLJU',font = 'arial 15 bold' , command = Exit, bg = 'green').place(x=100,y=140)
Button(root, text = 'UUESTI', font='arial 15 bold', command = Reset, bg = 'yellow' ).place(x=175 , y =140)


#infinite loop to run program
root.mainloop()
