資源簡介
壓縮包里面是四個Python寫的NAO機器人工程,分別實現了錄音并且回放,做一串動作、繞口令、和聲吶避障四個功能,代碼清晰,但愿對大家有用

代碼片段和文件信息
#!?/usr/bin/env?python
#-*-?coding:?utf-8?-*-
#錄音一段時間,再播放錄音
import?argparse?#?argparse是python用于解析命令行參數和選項的標準模塊??argparse模塊的作用是用于解析命令行參數
from?naoqi?import?ALProxy
import?time
tts?=?audio?=?record?=?aup?=?None
def?main(robot_IP?robot_PORT=9559):
????global?tts?audio?record?aup
????#?---------->?Connect?to?robot?<----------
????tts?=?ALProxy(“ALTextToSpeech“?robot_IP?robot_PORT)
????audio?=?ALProxy(“ALAudioDevice“?robot_IP?robot_PORT)
????record?=?ALProxy(“ALAudioRecorder“?robot_IP?robot_PORT)
????aup?=?ALProxy(“ALAudioPlayer“?robot_IP?robot_PORT)
????#?---------->?recording?<----------
????print?‘start?recording...‘
????record_path?=?‘/home/nao/record.wav‘
????record.startMicrophonesRecording(record_path?‘wav‘?16000?(0010))
????time.sleep(10)
????record.stopMicrophonesRecording()
????print?‘record?over‘
????#?---------->?playing?the?recorded?file?<----------
????fileID?=?aup.playFile(record_path?0.7?0)
if?__name__?==?“__main__“:
????parser?=?argparse.ArgumentParser()
????parser.add_argument(“--ip“?type=str?default=“192.168.1.100“?help=“Robot?ip?address“)#IP“192.168.2.100“改成當前NAO的IP地址
????parser.add_argument(“--port“?type=int?default=9559?help=“Robot?port?number“)
????args?=?parser.parse_args()
????#?---------->?執行main函數?<----------
????main(args.ip?args.port)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1455??2018-02-01?20:53??聲吶避障成果\luyin.py
?????文件?????????916??2018-02-02?21:34??聲吶避障成果\posture.py
?????文件????????1314??2018-02-01?20:10??聲吶避障成果\raokouling.py
?????文件????????1819??2018-02-06?15:09??聲吶避障成果\sennar.py
- 上一篇:使用Python進行圖像處理
- 下一篇:python進階篇34集全套視頻云盤
評論
共有 條評論