mirror of
https://github.com/6-robot/wpb_home.git
synced 2025-09-15 12:58:59 +08:00
sr_xfyun
This commit is contained in:
parent
37054be1eb
commit
2d1845cc05
@ -245,6 +245,14 @@ target_link_libraries(wpb_home_speech_recognition
|
||||
${catkin_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(wpb_home_sr_xfyun
|
||||
src/wpb_home_sr_xfyun.cpp
|
||||
)
|
||||
add_dependencies(wpb_home_sr_xfyun ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
target_link_libraries(wpb_home_sr_xfyun
|
||||
${catkin_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(wpb_home_velocity_control
|
||||
src/wpb_home_velocity_control.cpp
|
||||
)
|
||||
|
||||
15
wpb_home_tutorials/launch/sr_xfyun.launch
Normal file
15
wpb_home_tutorials/launch/sr_xfyun.launch
Normal file
@ -0,0 +1,15 @@
|
||||
<launch>
|
||||
|
||||
<!-- Run SR node -->
|
||||
<node pkg="xfyun_waterplus" type="iat_node" name="xfyun_iat_node" output="screen">
|
||||
<param name="cn" type="bool" value="true"/>
|
||||
</node>
|
||||
<!-- Run TTS node -->
|
||||
<node pkg="xfyun_waterplus" type="tts_node" name="xfyun_tts_node" />
|
||||
<!-- Run sound_play -->
|
||||
<node name="soundplay_node" pkg="sound_play" type="soundplay_node.py"/>
|
||||
|
||||
<!-- Run sr_xfyun -->
|
||||
<node pkg="wpb_home_tutorials" type="wpb_home_sr_xfyun" name="wpb_home_sr_xfyun" output="screen"/>
|
||||
|
||||
</launch>
|
||||
72
wpb_home_tutorials/src/wpb_home_sr_xfyun.cpp
Normal file
72
wpb_home_tutorials/src/wpb_home_sr_xfyun.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*********************************************************************
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2017-2020, Waterplus http://www.6-robot.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of the WaterPlus nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* FOOTPRINTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
/*!******************************************************************
|
||||
@author ZhangWanjie
|
||||
********************************************************************/
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
static ros::Publisher spk_pub;
|
||||
static std_msgs::String strSpeak;
|
||||
|
||||
void KeywordCB(const std_msgs::String::ConstPtr & msg)
|
||||
{
|
||||
//ROS_WARN("[KeywordCB] - %s",msg->data.c_str());
|
||||
int nFindIndex = 0;
|
||||
nFindIndex = msg->data.find("你好");
|
||||
if( nFindIndex >= 0 )
|
||||
{
|
||||
strSpeak.data = "很高兴认识你";
|
||||
spk_pub.publish(strSpeak);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ros::init(argc, argv, "wpb_home_sr_xfyun");
|
||||
|
||||
ros::NodeHandle n;
|
||||
ros::Subscriber sub_sr = n.subscribe("/xfyun/iat", 10, KeywordCB);
|
||||
spk_pub = n.advertise<std_msgs::String>("/xfyun/tts", 10);
|
||||
|
||||
ros::Rate r(10);
|
||||
while(ros::ok())
|
||||
{
|
||||
ros::spinOnce();
|
||||
r.sleep();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user