Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

text to speech program in python

import tkinter as tk
import pyttsx3
from tkinter import messagebox

engine = pyttsx3.init()

root = tk.Tk()
root.geometry("500x250")

randText = tk.Label(root, text="Type anything below").pack()
text2turn = tk.Text(root, height=100, width=200)
text2turn.tag_configure("center", justify='center')
text2turn.pack()

def sayText():
    text = text2turn.get(1.0, 'end-1c')

    if text == "":
        messagebox.showwarning("Error", "Please enter some text, I cannot say nothing")

    else:
        engine.say(text)
        engine.runAndWait()

submit = tk.Button(root, text="Say My Text!", command=sayText)
submit.place(x=215, y=200)

root.mainloop()
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #text #speech #program #python
ADD COMMENT
Topic
Name
3+4 =