I use gTTS python module to get mp3 from Google Text-To-Speech API and PyGame to play output mp3 files without opening external player (is there any simpler way to do it?)
However it seems like PyGame mixer doesn't free file resource, even after it's quit method.
phrase = "Hello!"
tts = gtts.gTTS(text=phrase, lang='en')
tts.save("googleTTS.mp3")
mixer.init(16000) # should be dynamic
mixer.music.load("googleTTS.mp3")
mixer.music.play()
while mixer.music.get_busy() == True:
continue
mixer.quit() # doesn't free resource?
phrase = "Bye!"
tts = gtts.gTTS(text=phrase, lang='en')
tts.save("googleTTS.mp3")
Last line gives exception:
IOError: [Errno 13] Permission denied: 'googleTTS.mp3'
I should notice that the problem isn't in tts.save function, cause code without mixer works fine.
How can I free mixer resource and use the same file over and over again?
Aucun commentaire:
Enregistrer un commentaire