You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that trying to call say_text() twice will cause the issue.
Running on Windows 11.
Python 3.10.10
PS D:\Projects\Auto-GPT> python scripts/main.py --speak --gpt3only
import os
from playsound import playsound
import requests
from config import Config
cfg = Config()
import gtts
# TODO: Nicer names for these ids
voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"]
tts_headers = {
"Content-Type": "application/json",
"xi-api-key": cfg.elevenlabs_api_key
}
def eleven_labs_speech(text, voice_index=0):
tts_url = "https://api.elevenlabs.io/v1/text-to-speech/{voice_id}".format(
voice_id=voices[voice_index])
formatted_message = {"text": text}
response = requests.post(
tts_url, headers=tts_headers, json=formatted_message)
if response.status_code == 200:
with open("speech.mpeg", "wb") as f:
f.write(response.content)
playsound("speech.mpeg")
os.remove("speech.mpeg")
return True
else:
print("Request failed with status code:", response.status_code)
print("Response content:", response.content)
return False
def gtts_speech(text):
tts = gtts.gTTS(text)
tts.save("speech.mp3")
playsound("speech.mp3")
os.remove("speech.mp3")
def say_text(text, voice_index=0):
if not cfg.elevenlabs_api_key:
gtts_speech(text)
else:
success = eleven_labs_speech(text, voice_index)
if not success:
gtts_speech(text)
if __name__ == "__main__":
say_text("Hello, this")
say_text("Hello, this")
Current behavior 😯
When using speak mode, it works for a random number of times but then eventually leads to this error.
Speak Mode: ENABLED
GPT3.5 Only Mode: ENABLED
Welcome to Auto-GPT! Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI: For example, 'Entrepreneur-GPT'
AI Name: Realestate-GPT
Error 263 for command:
open speech.mpeg
The specified device is not open or is not recognized by MCI.
Error 263 for command:
close speech.mpeg
The specified device is not open or is not recognized by MCI.
Failed to close the file: speech.mpeg
Traceback (most recent call last):
File "D:\Projects\Auto-GPT\scripts\main.py", line 275, in
prompt = construct_prompt()
File "D:\Projects\Auto-GPT\scripts\main.py", line 178, in construct_prompt
config = prompt_user()
File "D:\Projects\Auto-GPT\scripts\main.py", line 207, in prompt_user
print_to_console(
File "D:\Projects\Auto-GPT\scripts\main.py", line 30, in print_to_console
speak.say_text(f"{title}. {content}")
File "D:\Projects\Auto-GPT\scripts\speak.py", line 45, in say_text
success = eleven_labs_speech(text, voice_index)
File "D:\Projects\Auto-GPT\scripts\speak.py", line 27, in eleven_labs_speech
playsound("speech.mpeg")
File "C:\Users\faste\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 72, in _playsoundWin
winCommand(u'open {}'.format(sound))
File "C:\Users\faste\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 64, in winCommand
raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
Error 263 for command:
open speech.mpeg
The specified device is not open or is not recognized by MCI.
Expected behavior 🤔
it should speak
Your prompt 📝
# Paste your prompt here
The text was updated successfully, but these errors were encountered:
The error you're encountering might be caused by the playsound library not releasing the file properly after playing the sound. To resolve this issue, you can use a different method to play the sound, such as using the pydub library with the simpleaudio playback module.
Duplicates
Steps to reproduce 🕹
It seems that trying to call say_text() twice will cause the issue.
Running on Windows 11.
Python 3.10.10
PS D:\Projects\Auto-GPT> python scripts/main.py --speak --gpt3only
Current behavior 😯
When using speak mode, it works for a random number of times but then eventually leads to this error.
Speak Mode: ENABLED
GPT3.5 Only Mode: ENABLED
Welcome to Auto-GPT! Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI: For example, 'Entrepreneur-GPT'
AI Name: Realestate-GPT
Failed to close the file: speech.mpeg
Traceback (most recent call last):
File "D:\Projects\Auto-GPT\scripts\main.py", line 275, in
prompt = construct_prompt()
File "D:\Projects\Auto-GPT\scripts\main.py", line 178, in construct_prompt
config = prompt_user()
File "D:\Projects\Auto-GPT\scripts\main.py", line 207, in prompt_user
print_to_console(
File "D:\Projects\Auto-GPT\scripts\main.py", line 30, in print_to_console
speak.say_text(f"{title}. {content}")
File "D:\Projects\Auto-GPT\scripts\speak.py", line 45, in say_text
success = eleven_labs_speech(text, voice_index)
File "D:\Projects\Auto-GPT\scripts\speak.py", line 27, in eleven_labs_speech
playsound("speech.mpeg")
File "C:\Users\faste\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 72, in _playsoundWin
winCommand(u'open {}'.format(sound))
File "C:\Users\faste\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 64, in winCommand
raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
Error 263 for command:
open speech.mpeg
The specified device is not open or is not recognized by MCI.
Expected behavior 🤔
it should speak
Your prompt 📝
# Paste your prompt here
The text was updated successfully, but these errors were encountered: