Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gtts import gTTS
- import tkinter as tk
- def tts_button_click():
- text = text_entry.get()
- lang = lang_var.get()
- tts = gTTS(text, lang=lang)
- tts.save("hello.mp3")
- root = tk.Tk()
- root.title("Text-to-Speech")
- text_prompt = tk.Label(root, text="Enter text:")
- text_prompt.pack()
- text_entry = tk.Entry(root, width=50)
- text_entry.pack()
- lang_prompt = tk.Label(root, text="Choose language:")
- lang_prompt.pack()
- lang_var = tk.StringVar(root)
- lang_var.set("ru") # default value
- lang_dropdown = tk.OptionMenu(root, lang_var, "en", "fr", "de", "es", "it", "zh-cn", "ru")
- lang_dropdown.pack()
- tts_button = tk.Button(root, text="Speak", command=tts_button_click)
- tts_button.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement