1

In the above code I am able to convert the text 'Hello world' in the speech but how to close the .mp3 that is created. os.remove will not work until that .mp3 file is closed. Please suggest.

I am trying text to speech functionality

import os 
from gtts import gTTS

myobj = gTTS(text='Hello world', lang="en", slow=False) 

myobj.save("audio1.mp3")

os.startfile('audio1.mp3')

What I expect is audio1.mp3 should be closed.

Michael Fayad
  • 1,216
  • 1
  • 17
  • 38
Imran Khan
  • 49
  • 1
  • 1
  • 4

0 Answers0