Python Tkinter Text to Audio GUI App Using GTTS Library Full Tutorial

Python Tkinter Text to Audio GUI App Using GTTS Library Full Tutorial

Welcome Folks today in this blog post I will be talking about how to convert text to audio using gtts library in a gui application using tkinter library in python. Let’s get started step by step in the youtube video as follows.

 

Requirements

 

pip install tkinter

 

 

pip install gtts

 

Now after installing these two libraries copy paste the following code to make this application. In this block of code we will be making the gui application using tkinter and then writing the code to convert the text written to a audio file and play the audio file also. For Playing the audio file we will be installing another library called PlaySound.

 

pip install playsound

 

from tkinter import *

from gtts import gTTS 

from playsound import playsound


def convert_audio():
    
    address_info = address.get()
    
    language = 'en'
    
    myobj = gTTS(text=address_info, lang=language, slow=False)
    
    myobj.save("welcome.mp3") 
    
    playsound("welcome.mp3")
    
        
    print(address_info)
    
    address_entry.delete(0,END)    
    
    

app = Tk()

app.geometry("500x500")

app.title("Python Text to Audio App")

heading = Label(text="Python Text to Audio",bg="yellow",fg="black",font="10",width="500",height="3")

heading.pack()

address_field = Label(text="Text :")

address_field.place(x=15,y=70)

address = StringVar()


address_entry = Entry(textvariable=address,width="30")

address_entry.place(x=15,y=100)

button = Button(app,text="Convert to Audio",command=convert_audio,width="30",height="2",bg="grey")

button.place(x=15,y=140)

mainloop()

 

See also  FFMPEG Command to Convert MOV Video File to MP4 Video File in Windows 10 Full Tutorial For Beginners

 

 

Leave a Reply