I have written this tts code and downloaded all neccersarry packages on my system. It uses openai to be able and have converstations with me and works perfectly on my windows computer. However, when I run the code on my raspberry pie it comes up with errors, I have solved some of the errors but there are still alot I still dont know how to fix it.
Here Is My Code
import openai
import pyttsx3
import speech_recognition as sr
from api_key import API_KEY
from FaceRecTest import speak
openai.api_key = API_KEY
engine = pyttsx3.init()
r = sr.Recognizer()
mic = sr.Microphone(device_index=1)
voice = engine.getProperty('voices')
engine.setProperty('voice', voice[1].id)
engine.setProperty('rate', 180)
conversation = ""
user_name = "Zach"
bot_name = "Timothy"
while True:
with mic as source:
print("\nlistening...")
r.adjust_for_ambient_noise(source, duration=0.2)
audio = r.listen(source)
print("no longer listening.\n")
try:
user_input = r.recognize_google(audio)
except:
continue
if user_input.lower() == "exit" or user_input.lower() == "goodbye":
speak("Goodbye, Have a Good day!")
break
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
conversation += prompt
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
conversation += response_str + "\n"
print(response_str)
speak(response_str)
Here Is the Errors I am Getting
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib conf.c:5057:(parse_args) Unknown parameter AES0
ALSA lib conf.c:5217:(snd_config_expand) Parse arguments error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0}
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib conf.c:5057:(parse_args) Unknown parameter AES0
ALSA lib conf.c:5217:(snd_config_expand) Parse arguments error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0}
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
listening...
no longer listening.
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib conf.c:5057:(parse_args) Unknown parameter AES0
ALSA lib conf.c:5217:(snd_config_expand) Parse arguments error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0}
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
I used OpenAi to see if it can give a breakdown of what is wrong and this was the response:
"These messages are error messages from the Advanced Linux Sound Architecture (ALSA) library. They indicate that there were issues with trying to open certain sound devices or with certain sound card configurations. The specific issues mentioned in these messages, such as "Unknown field port" and "Invalid type for card," suggest that there may be problems with the configuration of the sound card or with the way the application is trying to access it. To resolve these issues, you may need to check the configuration of your sound card and ensure that the application is set up to use the correct device and settings. Additionally, you may need to update the ALSA driver or install additional software to support the sound card."
I updated all my ALSA drivers, and I am not sure what could be wrong with my sound card.If anybody can help me I will be so grateful, this is really stressing me out. Thank you.