语音识别bug

时间:2023-03-09 08:28:24
语音识别bug
#       如果消息为200,则表示talker在交互过程中未识别到用户的语音输入,开启人脸验证确认用户是否还在面前(排除噪声的影响)
# 确认时间为3秒,3秒都没有人脸,则确认用户不在.确认用户还在,则提醒对方重新说一下,如果不在,则取消交互,进入等待人脸介入环节.
# TODO:有人的话确认是否为本轮交互的同一人.
elif loop_count.data == :#unrecognized voice, reconfig if there still people talking to
start_time = time.time()
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if ret:
cv2.imwrite('tmp.jpg',frame)
with open("tmp.jpg", "rb") as fp:
image_binary = fp.read()
image_binary = base64.b64encode(image_binary)
post_data = {"Image":image_binary}
body = JSONEncoder().encode(post_data)
req = urllib2.Request(url, body)
response = urllib2.urlopen(req).read()
body = JSONDecoder().decode(response)
rospy.loginfo(body) if body['Id'] == 'UNKNOWN' or body['Id'] == 'None':#reconfiged nobody
msg.is_staff =
msg.name = 'nobody'
#self.face_result_pub.publish(msg)
print "nobody"
now_time = time.time()
if now_time - start_time <= :
continue
else:
self.face_result_pub.publish(msg)
break
else:#reconfiged unregistered people
msg.is_staff =
msg.name = 'unknown'
self.face_result_pub.publish(msg)
break
else:
pass

修改直到3秒结束,再发布 self.face_result_pub.publish(msg)