That's because my_file is a string, not a file handle. my_file = "Text To Speech.mp3"
When using with open, the file is closed when the context handler ends This might be of help: https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/ Note: In the email, your code did not get posted. I think it has something to do with nabble. When I clicked on that, then, I do see a couple different versions.