Welcome to DOGZILLA-Lite repository
2.Q&A
Free Q&A
Free Q&AFunction IntroductionFunctional ExperienceProgram source codeHow to replace the large model interfaceHow to run this example in terminalNote:How to change the length of recording timeFunctional principle
Function Introduction
This case is about starting a large program. You need to complete the configuration of the API-KEY related to the large model before you can use it normally. This function is a talkback function for communicating with users.
This function requires an Internet connection to work normally.
Functional Experience
- Turn on the robot dog first, enter the sample mode by pressing the button on the upper right of the "dog head", and then select the free question and answer function.

- After entering the free question and answer function, wake it up with voice, "lulu".

- When you hear a ding, you can say the question you want to ask.


- The robot dog will give an answer based on the question asked.

Program source code
- First, log in to the robot dog's system through VNC
- Then enter the terminal
x#cm4 runcd /home/pi/RaspberryPi-CM4-main/demos/Free_QA/#cm5 runcd /home/pi/RaspberryPi-CM5/demos/Free_QA/tree- Directory structure description ├── answer.mp3 #Synthesized audio ├── audio.py #Recording file ├── auto_platform.py #Dependencies required for recording ├── chatgpt_main.py #Main program ├── language_recognize.py #Speech recognition ├── libnyumaya.py #Speech wake-up ├── xinghou_tts.py #Synthesized audio └── xinghou_UltraAPI.py #Large language model interface
How to replace the large model interface
- You can start with the Python version of the platform's corresponding interface program and fill in the necessary information according to the platform's interface and instructions.
- Then encapsulate the executable file into a function. You can refer to the method of "xinghou_UltraAPI.py" and put it in the directory of point 2. For example, the added file name is "mychatgpt.py"
- Open the chatgpt_main.py file and replace from xinghou_UltraAPI import * with the newly added from mychatgpt import * at the top.
- Then find this place and replace it with your own encapsulated API function interface.

- Then restart the car and enter this function again, you can run the model platform you replaced. If it cannot run, it means there is an error, and you need to check the syntax and logic of the newly added file yourself.
How to run this example in terminal
- End the large program first to prevent screen distortion. For details on how to end the large program, please refer to the tutorial on ending the large program in Chapter 1. This will not be described here.
- Enter the following command in the terminal
x
#cm4 runcd ~/RaspberryPi-CM4-main#cm5 runcd /home/pi/RaspberryPi-CM5sudo python3 demos/Free_QA/chatgpt_main.py- When "waiting for keyword" appears, wake up the robot dog by saying "lu lu". After a few seconds, a scrolling prompt "current volume, boot threshold, end threshold" will appear. You can then start voice input to the robot dog.

Note:
- If the terminal reports an error timeout, the reason may be that the large model interface is blocked or the network is affected. Just restart the program.

How to change the length of recording time
- Terminal Input
x
#cm4 Runnano ~/RaspberryPi-CM4-main/demos/Free_QA/audio.py#cm5 Runnano ~/RaspberryPi-CM5/demos/Free_QA/audio.py- Find this place and change the place as shown in the figure below, then you can adjust the recording duration according to your own environment.

Note: start_threshold>end_threshold , the adjustment of these two values needs to be adjusted according to your own environment.
Functional principle
The specific flow chart is as follows:
