-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|