Hello! So I messed with my PiDog trying to get it to switch to a USB camera. I tried SunFounder’s code, but due to my inexperience with Python, I kept getting indentation errors (I barely passed intro to C++ and failed algorithms, so I’m not a programmer). I went to chat-gpt for help, as I failed to get it to switch to usb webcam and needed help getting it back to the onboard cam. Many scripts later, it worked with the onboard cam again. I then added more ChatGPT scripts for voice recognition.
I would take the .py file, scp it to my pi from my macbook, then ssh into my pi and run the program. As I had to reinstall the pidog files due to the camera issue, I didn’t want to tamper with the code until I could understand indentation requirements. So, all the scripts ran from the home directory and I never added anything new again to the py files found in the pidog folders.
Now I have an issue where my pidog quit speaking. It will only type a response, then it will say “speak started” but no sound comes out. I checked the volume with a command in ssh mode and raised it to 100%, but still no sound. I tried the commands to install all the sound and speech files that I found on the pidog assembly website, but still no sound.
On top of that, whatever ChatGPT wrote made it so my pidog hears everything…even when I don’t say anything. It can process about 10 words of less, then begins to process and blink yellow. If I remain very silent, after about 6-10 seconds it will hear, “Thanks for watching!” over and over. It will reply to that in text, and then I have to tell it that it’s hallucinating. I went looking for the speech recognition script I sent it, but i can’t find it.
I then asked ChatGPT for a script that would wait for a trigger word to listen. I included it here at the end of this post. It was supposed to delay listening until I said, “hey QI7,” but my pidog continues to hear everything.
My question: How can I make it go back to speaking output and typing input? If it’s hearing things I didn’t say, I’d prefer typing input only.
Thank you for. your time! This is my first robot and I love it! I wish I knew how to program, though! Here is the script from ChatGPT:
import speech_recognition as sr
def listen_for_trigger():
“”"
Continuously listens for the trigger word to activate command listening.
“”"
recognizer = sr.Recognizer()
mic = sr.Microphone()print("Initializing... Please wait.") with mic as source: recognizer.adjust_for_ambient_noise(source) # Adjust for background noise print("Ready. Say the trigger word (e.g., 'Hey QI7')") while True: try: with mic as source: print("Listening...") audio = recognizer.listen(source, timeout=10) command = recognizer.recognize_google(audio).lower() print(f"Recognized: {command}") if "hey QI7" in command: # Replace with your trigger word print("Trigger word detected. Awaiting command...") handle_command(recognizer, mic) # Calls a command handler else: print("No trigger word detected.") except sr.UnknownValueError: print("Sorry, I didn't catch that.") except sr.RequestError as e: print(f"Recognition service error: {e}") except KeyboardInterrupt: print("\nExiting...") break
def handle_command(recognizer, mic):
“”"
Handles commands after the trigger word is detected.
“”"
try:
print(“Listening for your command…”)
with mic as source:
audio = recognizer.listen(source, timeout=10)
command = recognizer.recognize_google(audio).lower()
print(f"Command received: {command}")if "bark" in command: print("PiDog says: Woof!") elif "sit" in command: print("PiDog is sitting.") elif "exit" in command: print("Exiting program...") raise KeyboardInterrupt else: print(f"Command not recognized: {command}") except sr.UnknownValueError: print("Sorry, I couldn't understand the command.") except sr.RequestError as e: print(f"Error with the recognition service: {e}")
if name == “main”:
listen_for_trigger()