0
我有這個功能,我需要在退出函數說(「一些文本」)之前關閉文件。如何在播放mp3文件後退出VLC
def say(self, text):
tts = gTTS(text, lang='fr')
file="text.mp3"
tts.save(file)
audio = MP3(file)
p = vlc.MediaPlayer(file)
p.play()
time.sleep((audio.info.length)) #to avoid it listening to itself
p.stop()
return file
因爲如果我不這樣做,我有這樣的錯誤
OS Error: [Errno -9993] Illegal combination of I/O device
我認爲,因爲我想聽聽剛過函數的調用說與此錯誤出現文件仍然打開。
注:我使用Python 3
It works thanks @Alexander –