Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import ttk
- import pyttsx3
- # Initialize the window
- window = tk.Tk()
- window.title("Text-to-Speech Converter")
- # Initialize the text-to-speech engine
- engine = pyttsx3.init()
- # Function to convert text to speech
- def convert_text():
- text = text_entry.get("1.0", tk.END).strip()
- if text:
- engine.say(text)
- engine.runAndWait()
- # Create a text entry widget
- text_entry = tk.Text(window, height=10, width=50)
- text_entry.pack(pady=10)
- # Create a button to convert text to speech
- convert_button = ttk.Button(window, text="Convert", command=convert_text)
- convert_button.pack()
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement