课程进度 69% · 第9/12章第9/12章 · 标签 1/4
— 1 —
人机交互基础
人机交互(HRI)研究人与机器人之间的有效沟通和协作。好的交互设计能提高用户接受度和任务效率。
交互方式
- 语音交互:语音识别和合成
- 手势交互:姿态识别
- 触觉交互:力反馈
- 视觉交互:表情和注视
— 2 —
语音控制
python
1
import speech_recognition as sr
2
import pyttsx3
3
4
recognizer = sr.Recognizer()
5
engine = pyttsx3.init()
6
7
def listen():
8
with sr.Microphone() as source:
9
audio = recognizer.listen(source)
10
return recognizer.recognize_google(audio, language='zh-CN')
11
12
def speak(text):
13
engine.say(text)
14
engine.runAndWait()
15
16
def process_command(text):
17
if '前进' in text: robot.move_forward()
18
elif '后退' in text: robot.move_backward()
19
elif '停止' in text: robot.stop()
20
else: speak('无法识别的命令')