I am making a simple program to read text out loud. The following code works as intended, but only once. Because after I run it a second time, it throws out the error: "PermissionError: [Errno 13] Permission denied: 'output.mp3'" It is weird that it always works the first time but stops after. I tried creating and closing the file, but it hasnt worked. What could I try next?
from gtts import gTTS
import os
from playsound import playsound
language="en"
output=gTTS(text="hello world", lang=language, slow=False)
open("output.mp3","w")
output.save("output.mp3")
playsound("output.mp3")