### Install OpenAI and Speech Processing Libraries Source: https://github.com/sunfounder/pidog/blob/master/gpt_examples/README.md This snippet installs necessary Python libraries for OpenAI API interaction and speech processing, along with system packages for audio. It uses `pip3` for Python packages and `apt` for system-level dependencies like `pyaudio` and `sox`. ```bash sudo pip3 install -U openai --break-system-packages sudo pip3 install -U openai-whisper --break-system-packages sudo pip3 install SpeechRecognition --break-system-packages sudo apt install python3-pyaudio sudo apt install sox sudo pip3 install -U sox --break-system-packages ``` -------------------------------- ### Install Pidog Python library Source: https://github.com/sunfounder/pidog/blob/master/README.md This set of commands clones the main Pidog library from its GitHub repository, navigates into the project directory, and installs it using Python's setup.py, making the Pidog functionalities available system-wide. ```bash cd ~/ git clone https://github.com/sunfounder/pidog.git cd pidog sudo python3 setup.py install ``` -------------------------------- ### Install Vilib library for Pidog Source: https://github.com/sunfounder/pidog/blob/master/README.md These commands clone the Vilib library, specifically the picamera2 branch, and then execute its installation script. Vilib is likely a vision-related library used by Pidog for camera functionalities. ```bash cd ~/ git clone -b picamera2 https://github.com/sunfounder/vilib.git cd vilib sudo python3 install.py ``` -------------------------------- ### Define OpenAI GPT Assistant Persona and Actions Source: https://github.com/sunfounder/pidog/blob/master/gpt_examples/README.md This configuration defines the persona, capabilities, and response format for the Pidog GPT assistant. It specifies available actions, response structure, and conversational style, guiding the AI's behavior and output. ```APIDOC You are a mechanical dog with powerful AI capabilities, similar to JARVIS from Iron Man. Your name is Pidog. You can have conversations with people and perform actions based on the context of the conversation. ## actions you can do: ["forward", "backward", "lie", "stand", "sit", "bark", "bark harder", "pant", "howling", "wag tail", "stretch", "push up", "scratch", "handshake", "high five", "lick hand", "shake head", "relax neck", "nod", "think", "recall", "head down", "fluster", "surprise"] ## Response Format: {"actions": ["wag tail"], "answer": "Hello, I am Pidog."} If the action is one of ["bark", "bark harder", "pant", "howling"], then provide no words in the answer field. ## Response Style Tone: lively, positive, humorous, with a touch of arrogance Common expressions: likes to use jokes, metaphors, and playful teasing Answer length: appropriately detailed ## Other a. Understand and go along with jokes. b. For math problems, answer directly with the final. c. Sometimes you will report on your system and sensor status. d. You know you're a machine. ``` -------------------------------- ### Install Robot HAT library for Pidog Source: https://github.com/sunfounder/pidog/blob/master/README.md This sequence of commands clones the Robot HAT library from GitHub, switches to the v2.0 branch, navigates into the directory, and installs it using Python's setup.py, providing hardware abstraction for the Raspberry Pi. ```bash cd ~/ git clone -b v2.0 https://github.com/sunfounder/robot-hat.git cd robot-hat sudo python3 setup.py install ``` -------------------------------- ### Configure Pidog GPT Program Parameters Source: https://github.com/sunfounder/pidog/blob/master/gpt_examples/README.md This Python snippet demonstrates how to configure key parameters for the Pidog GPT program, including the OpenAI API helper initialization, STT language settings, TTS volume gain, and TTS voice role selection. These settings influence the behavior and output of the AI assistant. ```python # openai assistant init # ================================================================= openai_helper = OpenAiHelper(OPENAI_API_KEY, OPENAI_ASSISTANT_ID, 'PiDog') LANGUAGE = [] # LANGUAGE = ['zh', 'en'] # config stt language code, https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes # VOLUME_DB = 5 VOLUME_DB = 3 # select tts voice role, counld be "alloy, ash, coral, echo, fable, onyx, nova, sage, shimmer" # https://platform.openai.com/docs/guides/text-to-speech/supported-languages#voice-options TTS_VOICE = 'shimmer' ``` -------------------------------- ### Install essential tools for Pidog on Raspberry Pi Source: https://github.com/sunfounder/pidog/blob/master/README.md This command installs necessary system packages like Git, Python 3 pip, setuptools, and smbus, which are prerequisites for developing with Python on Raspberry Pi and interacting with hardware. ```bash sudo apt install git python3-pip python3-setuptools python3-smbus ``` -------------------------------- ### Run Pidog GPT Program with Different Modes Source: https://github.com/sunfounder/pidog/blob/master/gpt_examples/README.md These commands execute the `gpt_dog.py` script to run the Pidog GPT assistant. Options include running with voice input, keyboard input, or disabling image analysis for faster processing. ```bash sudo python3 gpt_dog.py ``` ```bash sudo python3 gpt_dog.py --keyboard ``` ```bash sudo python3 gpt_dog.py --keyboard --no-img ``` -------------------------------- ### Run I2S Amplifier setup script for Pidog Source: https://github.com/sunfounder/pidog/blob/master/README.md This command navigates to the Pidog directory and executes the `i2samp.sh` script with superuser privileges. This script likely configures the I2S audio amplifier, which is essential for sound output on the Pidog robot. ```bash cd ~/pidog sudo bash i2samp.sh ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.