播放 mp3 文件后如何退出 VLC
How to quit VLC after playing a mp3 file
我有这个函数,我需要在退出函数之前关闭文件 say("some text").
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
我认为发生此错误是因为我试图在调用函数 say 之后立即收听并且文件仍处于打开状态。
nb:我正在与 Python 3
合作
虽然我没有使用 TTS 的经验,但如果你只是做它不应该工作吗?close(os.getcwd()+'/'+file)
?
我有这个函数,我需要在退出函数之前关闭文件 say("some text").
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
我认为发生此错误是因为我试图在调用函数 say 之后立即收听并且文件仍处于打开状态。
nb:我正在与 Python 3
合作虽然我没有使用 TTS 的经验,但如果你只是做它不应该工作吗?close(os.getcwd()+'/'+file)
?