1

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")
Nick Heumann
  • 111
  • 1
  • Does this answer your question? [PermissionError: \[Errno 13\] Permission denied](https://stackoverflow.com/questions/36434764/permissionerror-errno-13-permission-denied) – esqew Aug 18 '21 at 20:52

1 Answers1

0

The audio file needs to have a different name for every recording even if it’s the same. I find randint or datetime is a good solution to the unique name issue.

Tyler
  • 1