Welcome to Raspbot V2 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
5.Intelligent action choreography
Intelligent Action Choreography
Intelligent Action ChoreographyExperiment ObjectiveExperiment Quick Start StepsExperimental ResultsMain Source Code AnalysisOverall flow chart for this experiment(Selected section)1. Customizing the English Version
Experiment Objective
Use language to communicate with a smart car, enabling it to perform a specific action based on relevant semantics.
Experiment Quick Start Steps
- Power on the computer, wait for the IP address to appear on the OLED screen, and then log in remotely via VNC to the Raspberry Pi desktop.
- Open a new terminal and enter the command:
xxxxxxxxxxcd /home/pi/project_demo/09.AI_Big_Model/- Modify the file configuration:
xxxxxxxxxxgedit API_KEY.pySet AI_Agent = Flase, as shown in the image.

- Then, fill in TONYI_KEY for the Chinese version and openAI_KEY for the English version. Save and exit the API_KEY.py file, then run the following command:
xxxxxxxxxx#Start command for the Chinese versionpython3 Car_Choreography/AIagent_main.pyxxxxxxxxxx#Start command for the English versionpython3 Car_Choreography/AIagent_main_en.py- The car enters the wake-up state. For international users, use the wake-up word: "Hi, yahboom."
- After successfully waking up, the car will respond with a horn sound. After waiting for 1 second, you can then state the desired action sequence.
- The smart car will analyze the language based on semantics, execute a series of action commands, and provide some dialogue feedback.
- This concludes the execution of the actions in the dialogue sequence. To continue the conversation, repeat steps 5-8.
Experimental Results
- Waiting for wakeup

- Start recording

- After speech recognition, provide speech feedback and execute corresponding action commands

Main Source Code Analysis
xxxxxxxxxxdef play_agent(): print("start") global response,agent_plan_output,xuanxin while True: if detect_keyword(): xuanxin = 1 os.system("pkill mplayer") Car_Reset() time.sleep(.2) if os.path.exists('./myrec.wav'): os.remove('./myrec.wav') time.sleep(0.2) start_recording() time.sleep(0.2) if TTS_IAT_Tongyi: rectext = rec_wav_music_Tongyi() else: rectext = rec_wav_music() if rectext != "": print("Q:"+ rectext) try: if AI_Agent: agent_plan_output = eval(Car_tonyi_agent_online(rectext)) else: agent_plan_output = eval(Car_Agent_Plan(rectext)) response = agent_plan_output['response'] except: display_text = "There was an error in obtaining the action information, please try again..." print(display_text) continue print("A:"+response)detect_keyword: Wake-up function for the wake-up word
- Chinese version-specific configuration rec_wav_music_Tongyi: Tongyi Qianwen voice recognition. Valid only when TTS_IAT_Tongyi = True and the Chinese version is used. rec_wav_music: iFlytek Spark voice recognition solution. Valid only when TTS_IAT_Tongyi = False and the Chinese version is used. TTS_IAT_Tongyi: Configured in API_KEY.py
Car_tonyi_agent_online: This API executes actions based on the agent configured on the Tongyi Qianwen platform. This API is effective when AI_Agent = True. This API also configures the viewing and selection section. Car_Agent_Plan(rectext): This API executes actions based on information from the locally deployed Car_agent.py. This API is effective when AI_Agent = False.
- The English version's speech synthesis and recognition are already packaged, so you don't need to worry about them here.
Modifying the recording duration, start threshold, and end threshold
- In the terminal, enter:
xxxxxxxxxxcd /home/pi/project_demo/09.AI_Big_Model/Car_Choreography/gedit Car_audio.py- Find the source code shown below.

- start_threshold: The threshold for starting recording when sound is detected (this can be lowered to 5000 in quiet environments, and increased to 150000+ in noisy environments).
- end_threshold: The threshold for stopping recording when sound is detected. A value of 30-50% of start_threshold is recommended.
- endlast: The number of times to stop recording. Here, it is 15. For example, if 15 consecutive sound values meet the stop threshold, recording will automatically terminate.
- max_record_time: Recording duration, set to 5 here. Note: start_threshold > end_threshold. This is a required rule, and its value can be determined by the environment.
Overall flow chart for this experiment

(Selected section)
1. Customizing the English Version
- Enter the following command in the terminal:
xxxxxxxxxxcd /home/pi/project_demo/09.AI_Big_Model/Car_Choreography/gedit Car_agent_en.py
Simply modify this file. Note: Do not change the content in the green box. You can add to it, but you cannot delete or modify it.

You can modify this file to use the action interface. This requires some basic knowledge, and it is not recommended for beginners to modify it directly.
- After completing the modification, you can replace the large model by editing Car_Online_API.py.
xxxxxxxxxxcd /home/pi/project_demo/09.AI_Big_Model/Car_Choreography/gedit Car_Online_API.py
Then modify the model indicated by the red box.

Learn about the models that can be replaced First, visit the website openrouter

Using deepseak as an example:


- Finally, run the startup command. ```shell cd /home/pi/project_demo/09.AI_Big_Model/ python3 Car_Choreography/AIagent_main_en.py
xxxxxxxxxx**Tips**List some dialogues1. Drive forward for 2 seconds, then change the taillights to gold, turn left halfway, and nod.2. Change the taillights to a more romantic color and play Jay Chou's "Rice Fragrance."3. Stop 15 cm away from the obstacle.