Advertisement
CodeCrusader

Text To Speech App GUI (Free)

Jun 10th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | Software | 0 0
  1. import tkinter as tk
  2. from tkinter import ttk
  3. import pyttsx3
  4.  
  5. # Initialize the window
  6. window = tk.Tk()
  7. window.title("Text-to-Speech Converter")
  8.  
  9. # Initialize the text-to-speech engine
  10. engine = pyttsx3.init()
  11.  
  12. # Function to convert text to speech
  13. def convert_text():
  14.     text = text_entry.get("1.0", tk.END).strip()
  15.     if text:
  16.         engine.say(text)
  17.         engine.runAndWait()
  18.  
  19. # Create a text entry widget
  20. text_entry = tk.Text(window, height=10, width=50)
  21. text_entry.pack(pady=10)
  22.  
  23. # Create a button to convert text to speech
  24. convert_button = ttk.Button(window, text="Convert", command=convert_text)
  25. convert_button.pack()
  26.  
  27. window.mainloop()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement