Skip to content

Commit

Permalink
Text to Speech example
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaminus committed May 26, 2018
1 parent 707ac93 commit a11f56a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Text to Speech example/TTSGui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from tkinter import *
import pyttsx3 as pyttsx
engine=pyttsx.init()


def sRate():
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[1].id)

def male():
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[0].id)

def female():
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[2].id)


def speak():
text_entered=textentry.get()
engine.say(text_entered)
engine.runAndWait()
def exit_program():
window.destroy()
exit()



window=Tk()


window.configure(background="black")
window.title("Text to Speech Program")
Label(window,text="Enter text",bg="black", fg="white",font="Arial 16 bold").grid(row=0,column=0,sticky=W)
textentry=Entry(window,width=20,bg="white")
textentry.grid(row=1,column=0,sticky=W)
Button(window,text="Submit",width=6,command=speak).grid(row=2,column=0,sticky=W)
Label(window,text="Click to close",bg="black",fg="white",font="Arial 12 underline").grid(row=3,column=0,sticky=W)
Label(window,text="Gender",bg="black",fg="white",font="Arial 12 underline").grid(row=0,column=3,sticky=E)
Button(window,text="Male",width=6,command=male).grid(row=3,column=2,sticky=E)
Button(window,text="Female",width=6,command=sRate).grid(row=3,column=3,sticky=E)
Button(window,text="Female 2",width=6,command=female).grid(row=3,column=4,sticky=E)



Button(window,text="Close",width=6,command=exit_program).grid(row=4,column=0,sticky=W)


window.mainloop()

0 comments on commit a11f56a

Please sign in to comment.