forked from codehouseindia/Python-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEXT TO SPEECH.py
63 lines (49 loc) · 995 Bytes
/
TEXT TO SPEECH.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#SPEECH TO TEXT
# Modules to be imported pyttsx3 and Tkinter
import tkinter as tk
from tkinter import *
import pyttsx3
engine=pyttsx3.init("sapi5")
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[0].id)
root=tk.Tk()
root.title("TEXT TO SPEECH")
root.geometry("600x200")
root.config(background="#67E6DC")
def speak(audio):
engine.say(audio)
engine.runAndWait()
def translate():
audio=text1.get()
speak(audio)
welcome=Label(
root,
text="TEXT TO SPEECH BY ABHRA",
font=("Arial",20,"bold"),
bg="#45CE30",
fg="black",
).pack()
enter_text=Label(
root,
text="ENTER YOUR TEXT BELOW",
font=("Arial",18,"bold"),
bg="#FFF222",
fg="black",
relief=GROOVE
).pack(padx=5,pady=5)
text1=StringVar()
text_area=Entry(
root,
font="Arial 18",
width=30,
textvariable=text1,
).pack(padx=3,pady=5)
trans=Button(
root,
text="SPEAK",
font=("Verdana",15,"bold"),
bg="yellow",
fg="RED",
relief=SOLID,
command=translate).pack(padx=5,pady=10)
root.mainloop()