0
写入音频文件时出现错误。Errno 13权限被拒绝:'file.mp3'Python
基本上,我覆盖了mp3中的数据,只要我的函数被调用,然后播放它。
它的作品第一次通过,但随后给我[Errno 13] Permission denied: 'file.mp3'
然后。
下面是代码:
def speech(self, response):
audio_file = "response.mp3"
tts = gTTS(text=str(response), lang="en")
tts.save(audio_file)
pygame.mixer.init()
pygame.mixer.music.load(audio_file)
pygame.mixer.music.play()
错误是在tts.save
线。
更多信息:
Traceback (most recent call last):
File "myprojectpath", line 63, in speech
tts.save(audio_file)
File "C:\Python35\lib\site-packages\gtts\tts.py", line 93, in save
with open(savefile, 'wb') as f:
谢谢!
也许程序(播放它)阻止访问文件的概率。 – furas
会有一种方法来测试吗? – Jaromando
你是否以管理员身份启动python脚本? Windows用户有权访问此文件吗? 这里验证进程访问的文件或文件夹的方式http://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows 也你在脚本之前打开这个文件吗? –