## 3 Design and Implementation
### Software Architecture  
This section describes the software architecture and libraries in the development process. While the voice bonnet connects the peripherals, the RPi handles the processing. The AIY Voice kit [68] ships with a Debian/Raspbian-based system image [87] and a Python library [79] for working with the Voice Bonnet and connected peripherals. Preparing the RSC prototype involved integrating various components and software libraries to enable its functionality and provide seamless user interaction. To provide coherent, context-aware text responses that enable engaging, interactive conversations, we selected OpenAI's text_davinci003, a variant of the Generative Pretrained Transformer (GPT) model [88]. OpenAI's official Python library (v0.27.4) [89] provided a convenient, user-friendly interface for their NLP API. The RSC, in its current state, engages users using a demo interaction loop (Figure 8) that was written in Python v3.7.3 [90] using compatible speech and language-processing libraries. Multiple speech-processing libraries enable automatic speech-to-text (STT) and text-to-speech (TTS) transcription. 'PyAudio' v0.21.1 [91] helps the RSC listen and speak by accessing the microphones (record audio) and speaker (play audio). The 'SpeechRecognition' library v3.9.0 [92] allows the RSC to interpret spoken user inputs by transcribing  
Figure 7: Custom expansion board installed in the AIY Voice Bonnet extension header. Depicted on the brown protoboard to the right is a bidirectional logic level shifter (blue). To the left of the protoboard is a USB power-supply connector and two servo pin headers. spoken language (audio) into written text. The 'pyttsx3' library v2.90 [93] enables the RSC to respond to responses by converting text to speech (audio). In addition to audio-related libraries, the RSC also features additional peripherals and their libraries (Figure 9). The 'adafruit-circuitpython-neopixel' library version 6.3.8 [94] integrates and controls the NeoPixel RGB LED ring. It provides an interface for managing the colour and brightness of the 16 individually addressable NeoPixel LEDs on the ring. This level of customizability allows for dynamic lighting effects, contributing to the interactive experience. Figure 8: Interaction-state loop diagram. After the loop starts, a brief setup phase commences. Once it is ready for user input (question), the RSC listens, transcribes spoken words into text, and sends the question to OpenAI for processing. The RSC then ‘speaks’ the response from the API to the user. Figure 9: HRI block diagram and library flow. Auditory interaction (green, **right**) incorporates preinstalled libraries: AIY (enabling Voice Bonnet I/O access), pyttsx3 (text-to-speech), and pyaudio (audio input/output). We installed OpenAI and SpeechRecognition to facilitate comprehensive auditory interaction. To accommodate physical (blue, **bottom left**) and visual (yellow, **top left**) interactions, we installed the CircuitPy and Adafruit-NeoPixel libraries. Both physical and visual interaction are governed by auditory interaction (NLP). The 'AJY Voice Bonnet' library [79; 87], in addition to providing access to the speaker and microphones, also provides access to servos and buttons connected to the Voice Bonnet. We aimed to establish a basic interactive and functional baseline for the RSC that can be continuously improved and expanded on in an open-source community. The class diagram (Figure 10) illustrates how all the peripherals communicate with their qualities (attributes) and data operations (methods). The visibility of an attribute or method sets the accessibility for that attribute or method: a private (\(-\)) method cannot be accessed by another class, whereas another class can access a public (\(+\)) method. The lines represent the relationship between objects and classes. The empty diamond terminator denotes that OpenAI API operates independently of the RPi because the computation is offloaded to the OpenAI services.