AutoGPT
AutoGPT copied to clipboard
TTS Eleven Labs - Permission Denied
Duplicates
- [X] I have searched the existing issues
Steps to reproduce 🕹
I've setup the Eleven Labs API. And i can hear the first message (welcome or resuming the preceding session), but then I have the following error :
Traceback (most recent call last):
File "F:\autogpt\scripts\main.py", line 275, in <module>
prompt = construct_prompt()
File "F:\autogpt\scripts\main.py", line 178, in construct_prompt
config = prompt_user()
File "F:\autogpt\scripts\main.py", line 192, in prompt_user
print_to_console(
File "F:\autogpt\scripts\main.py", line 30, in print_to_console
speak.say_text(f"{title}. {content}")
File "F:\autogpt\scripts\speak.py", line 45, in say_text
success = eleven_labs_speech(text, voice_index)
File "F:\autogpt\scripts\speak.py", line 25, in eleven_labs_speech
with open("speech.mpeg", "wb") as f:
PermissionError: [Errno 13] Permission denied: 'speech.mpeg'
Current behavior 😯
No response
Expected behavior 🤔
No response
Your prompt 📝
# Paste your prompt here
It looks like playsound isn't releasing a lock on the file, I don't have a solution but here is the same issue discussed in a different project https://github.com/TaylorSMarks/playsound/issues/21
Maybe not helping with 11labs but anyhow:
TIP: If you leave ELEVENLABS_API_KEY= (empty) and start with scripts/main.py --speak it will use your local windows TTS without the need for 11labs.
Same error of Permission denied when remove the Eleven Labs key and using default TTS. I think it's related to a permission with my Python, but I don't know how. Can be the reason that I don't have access yet to GPT-4 ? And I'm using the default of GPT-3.
Traceback (most recent call last):
File "f:\autogpt2\scripts\main.py", line 275, in <module>
prompt = construct_prompt()
File "f:\autogpt2\scripts\main.py", line 178, in construct_prompt
config = prompt_user()
File "f:\autogpt2\scripts\main.py", line 192, in prompt_user
print_to_console(
File "f:\autogpt2\scripts\main.py", line 30, in print_to_console
speak.say_text(f"{title}. {content}")
File "f:\autogpt2\scripts\speak.py", line 43, in say_text
gtts_speech(text)
File "f:\autogpt2\scripts\speak.py", line 37, in gtts_speech
tts.save("speech.mp3")
File "C:\Users\Houssen\AppData\Local\Programs\Python\Python310\lib\site-packages\gtts\tts.py", line 324, in save
with open(str(savefile), "wb") as f:
PermissionError: [Errno 13] Permission denied: 'speech.mp3'
@HoussenMoshine is this still an issue for you or can this be closed?
Sorry to jump in, I'm experiencing a similar issue with play sound in the stable build (4/15/2023)
File "D:\Merlin\Auto-GPT-stable\autogpt\speak.py", line 112, in speak success = eleven_labs_speech(text, voice_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Merlin\Auto-GPT-stable\autogpt\speak.py", line 53, in eleven_labs_speech with open("speech.mpeg", "wb") as f: ^^^^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied: 'speech.mpeg'
I attempted to add a short delay in the code to see if it was just a timing problem, but it seems issue is a bit more complex then that...
python -m autogpt --gpt3only
Having the same issue. Unfortunate. :(
Hi @HoussenMoshine based on your traceback log, it looks like you're using the old version of AutoGPT. Can you update and use the latest stable version please and try again?
@danielmrussell if you're using the latest stable version, can you rerun it but please include the traceback message and attach a log file for dev's reference please?
I've updated to the last version, same error :
Traceback (most recent call last):
File "C:\Users\Houssen\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\Houssen\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "f:\autogpt\autogpt\speech\say.py", line 33, in speak
success = VOICE_ENGINE.say(text, voice_index)
File "f:\autogpt\autogpt\speech\base.py", line 33, in say
return self._speech(text, voice_index)
File "f:\autogpt\autogpt\speech\gtts.py", line 19, in _speech
tts.save("speech.mp3")
File "C:\Users\Houssen\AppData\Local\Programs\Python\Python310\lib\site-packages\gtts\tts.py", line 324, in save
an with open(str(savefile), "wb") as f:
PermissionError: [Errno 13] Permission denied: 'speech.mp3'
I figured it out. The problem is in playsound itself. They forgot to close the MCI device, so it holds onto files forever, and then os.remove() gets called but silently defers actual removals of the file. Actually, I think Windows added some feature at some point if I recall correctly to defer file deletions requested by one thread or process until an MCI device was done using it. So what I think is happening is that Windows is getting the request to delete the file, seeing that the MCI device is still open and using the file, and thus queues the deletion until the MCI device is destroyed, which happens automatically on the program end. I confirmed this by writing a version of the _speech() function that writes to different file names each time and watching what they do in Windows Explorer.
If using a single file name as the original code does, this means that upon the next run of _speech, the file cannot be written to anew.
The solution was:
Edit C:\Python310\Lib\site-packages\playsound.py, adding very last line below, telling MCI to close.
def winCommand(*command):
buf = c_buffer(255)
command = ' '.join(command).encode(getfilesystemencoding())
errorCode = int(windll.winmm.mciSendStringA(command, buf, 254, 0))
if errorCode:
errorBuffer = c_buffer(255)
windll.winmm.mciGetErrorStringA(errorCode, errorBuffer, 254)
exceptionMessage = ('\n Error ' + str(errorCode) + ' for command:'
'\n ' + command.decode() +
'\n ' + errorBuffer.value.decode())
raise PlaysoundException(exceptionMessage)
return buf.value
alias = 'playsound_' + str(random())
winCommand('open "' + sound + '" alias', alias)
winCommand('set', alias, 'time format milliseconds')
durationInMS = winCommand('status', alias, 'length')
winCommand('play', alias, 'from 0 to', durationInMS.decode())
if block:
sleep(float(durationInMS) / 1000.0)
winCommand('close', alias) # Added line to close the sound file, because this was holding onto files forever till program close otherwise
But it appears this issue has been fixed in a more recent playsound.py. So really, we ought to just update that.
Try and use the #tech-support channel in discord for these issues. We don’t have the capacity to help debug in GitHub issues for problems like this
@danielmrussell open a pr if you get a chance with that fix