Advertisement
TTpocToXaKep

Text to Speech TKINTER BEST MENU 10 LANGUAGES BEST CHOOSE

Feb 7th, 2023
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. from gtts import gTTS
  2. import tkinter as tk
  3.  
  4. def tts_button_click():
  5.     text = text_entry.get()
  6.     lang = lang_var.get()
  7.     tts = gTTS(text, lang=lang)
  8.     tts.save("hello.mp3")
  9.  
  10. root = tk.Tk()
  11. root.title("Text-to-Speech")
  12.  
  13. text_prompt = tk.Label(root, text="Enter text:")
  14. text_prompt.pack()
  15.  
  16. text_entry = tk.Entry(root, width=50)
  17. text_entry.pack()
  18.  
  19. lang_prompt = tk.Label(root, text="Choose language:")
  20. lang_prompt.pack()
  21.  
  22. lang_var = tk.StringVar(root)
  23. lang_var.set("ru") # default value
  24.  
  25. lang_dropdown = tk.OptionMenu(root, lang_var, "en", "fr", "de", "es", "it", "zh-cn", "ru")
  26. lang_dropdown.pack()
  27.  
  28. tts_button = tk.Button(root, text="Speak", command=tts_button_click)
  29. tts_button.pack()
  30.  
  31. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement