The program runs only twice. Later, the error occurs. I don't know why it works twice and then stops.
import tkinter, sys, pygame
from tkinter import messagebox
from gtts import gTTS
soundfile="file.mp3"
def ex():
sys.exit()
The main problem is there:
def read():
t = e.get()
tts = gTTS(text=t, lang="en")
tts.save(soundfile)
pygame.mixer.init(frequency=16000, size=-16, channels=2, buffer=4096)
pygame.mixer.music.load(soundfile)
pygame.mixer.music.set_volume(1.0)
pygame.mixer.music.play(0,0.0)
while pygame.mixer.music.get_busy()==True:
continue
pygame.quit()
Next is the code for the buttons.
def clear():
e.delete(0, 'end')
main = tkinter.Tk()
e = tkinter.Entry(main, justify = "center")
l = tkinter.Label(main, text = "Write text")
b1 = tkinter.Button(main, text = "Read", command = read)
b2 = tkinter.Button(main, text = "Clear", command = clear)
b3 = tkinter.Button(main, text = "Exit", command = ex)
So, I don't have any idea to fix it.