pocketsphinx

ROS kinetic语音识别
indigo教程kinetic教程
实验之后只能识别0-9英文,中文包下载之后没有lm文件夹,其次修改不成功。
原因是
https://packages.debian.org/jessie/pocketsphinx-hmm-zh-tdt
https://packages.debian.org/jessie/pocketsphinx-lm-zh-hans-gigatdt
需要都下载

        self.asr.set_property('lm', '/usr/share/pocketsphinx/model/lm/zh_CN/gigatdt.5000.DMP')
        self.asr.set_property('dict', '/usr/share/pocketsphinx/model/lm/zh_CN/mandarin_notone.dic')
        self.asr.set_property('hmm', '/usr/share/pocketsphinx/model/hmm/zh/tdt_sc_8k')

语音识别率应该说是特别底。

xfei_asr

https://www.ncnynl.com/archives/201702/1287.html

tts_subscribe_speak.cpp
iat_sample.c
asr_sample.c
iat_publish_speak.cpp
iat_record.c
tts_sample.c
sch_speak.c
sch_text.c

科大讯飞 错误的码对应说明:https://blog.csdn.net/wzqnn/article/details/77478858
error code: 10201.MSP_ERROR_NET_OPENSOCK这个是网络差导致的,重新刷新网络在连一次就OK
iat_publish_speak可以在输出rostopic pub xfwakeup std_msgs/String “ok” 之后进行说话 15s 然后识别内容发布,还挺准的。
虽然在我的电脑上会出现 data: !!python/str "\u60F3\u8981\u53BB\u5395\u6240\u3002"的提示(rostopic echo的时候显示的)但是不影响接收节点的判断
而且可以发布语音。很不错。
roscore
rosrun xfei_asr iat_publish_speak
rostopic pub xfwakeup std_msgs/String “ok”
rosrun voice_recongintion reciever.py

#! /usr/bin/env python
import rospy
from std_msgs.msg import String

rospy.init_node('subscriber')
def callback(msg):    
	print msg.data    
sub = rospy.Subscriber('/xfspeech',String,callback)
rospy.spin()

语音控制机器人去某个地方

语音控制机器人转速:https://www.ncnynl.com/archives/201905/3027.html
Turtlebot入门-编码实现定点自导航:https://www.ncnynl.com/archives/201609/800.html
Turtlebot入门教程-多个目标点自主导航 :https://www.ncnynl.com/archives/201702/1385.html
就这三个教程,更改python代码实现说“去厕所”然后就导航到地图某个地点
#建图
rosrun slam_karto slam_karto
roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch turtlebot_rviz_launchers view_navigation.launch
roslaunch turtlebot_teleop keyboard_teleop.launch
rosrun map_server map_saver -f /home/asber/turtlebot_custom_maps/tutorial
#定位导航
roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch turtlebot_gazebo amcl_demo.launch map_file:=/home/asber/turtlebot_custom_maps/tutorial.yaml
roslaunch turtlebot_rviz_launchers view_navigation.launch
#语音控制去哪里(实现确定好位置的地图坐标)
首先需要在rviz找到一个可以到达的点,修改下面代码中的目的地
roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch turtlebot_gazebo amcl_demo.launch map_file:=/home/asber/turtlebot_custom_maps/tutorial.yaml
roslaunch turtlebot_rviz_launchers view_navigation.launch
rosrun voice_recongintion reciever.py
rosrun xfei_asr iat_publish_speak
rostopic pub xfwakeup std_msgs/String “ok”
然后说 去厕所。
附代码:

#! /usr/bin/env python
# coding=utf-8
import rospy
from std_msgs.msg import String
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
import actionlib
from actionlib_msgs.msg import *
from geometry_msgs.msg import Pose, Point, Quaternion

class GoToPose():
    def __init__(self):
        self.goal_sent = False 

	# What to do if shut down (e.g. Ctrl-C or failure)
        rospy.on_shutdown(self.shutdown)

        # Tell the action client that we want to spin a thread by default
        self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
        rospy.loginfo("Wait for the action server to come up")

	# Allow up to 5 seconds for the action server to come up
        self.move_base.wait_for_server(rospy.Duration(5))

    def goto(self, pos, quat):

        # Send a goal
        self.goal_sent = True
        goal = MoveBaseGoal()
        goal.target_pose.header.frame_id = 'map'
        goal.target_pose.header.stamp = rospy.Time.now()
        goal.target_pose.pose = Pose(Point(pos['x'], pos['y'], 0.000),
                                     Quaternion(quat['r1'], quat['r2'], quat['r3'], quat['r4']))

	# Start moving
        self.move_base.send_goal(goal)

	# Allow TurtleBot up to 120 seconds to complete task
        success = self.move_base.wait_for_result(rospy.Duration(120)) 

        state = self.move_base.get_state()
        result = False

        if success and state == GoalStatus.SUCCEEDED:
            # We made it!
            result = True
        else:
            self.move_base.cancel_goal()

        self.goal_sent = False
        return result

    def shutdown(self):
        if self.goal_sent:
            self.move_base.cancel_goal()
        rospy.loginfo("Stop")
        rospy.sleep(1)

def callback(msg):    
    print msg.data    
    if msg.data == "去厕所。":
        print "OK"
        try:
            navigator = GoToPose()
            position = {'x': 1.0, 'y' : -4.0}
            quaternion = {'r1' : 0.000, 'r2' : 0.000, 'r3' : 0.000, 'r4' : 1.000}
            rospy.loginfo("Go to (%s, %s) pose", position['x'], position['y'])

            success = navigator.goto(position, quaternion)

            if success:
                rospy.loginfo("Hooray, reached the desired pose")
            else:
                rospy.loginfo("The base failed to reach the desired pose")

            # Sleep to give the last log messages time to be sent
            rospy.sleep(1)
        except rospy.ROSInterruptException:
            rospy.loginfo("Ctrl-C caught. Quitting")

rospy.init_node('subscriber')
sub = rospy.Subscriber('/xfspeech',String,callback)
rospy.spin()
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐