ros2语音交互,实现机器人【口耳】,使用科大讯飞sdk

ros1参考:https://blog.csdn.net/qq_39400324/article/details/125351722

  • ros1转ros2问题
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"int main(int argc, char* argv[])
{// 初始化ROSrclcpp::init(argc, argv);auto node = std::make_shared<rclcpp::Node>("voiceRecognition");rclcpp::WallRate loop_rate(10.0);// 声明Publisher和Subscriber// 订阅唤醒语音识别的信号rclcpp::Subscription<std_msgs::msg::String>::SharedPtr wakeUpSub = node->create_subscription<std_msgs::msg::String>("voiceWakeup", 1000, WakeUp);   // 订阅唤醒语音识别的信号    rclcpp::Publisher<std_msgs::msg::String>::SharedPtr voiceWordsPub = node->create_publisher<std_msgs::msg::String>("voiceWords", 1000);  RCLCPP_INFO(node->get_logger(), "Sleeping...");int count=0;// kd code downint ret = MSP_SUCCESS;int upload_on =    1; /* whether upload the user word *//* login params, please do keep the appid correct */const char* login_params = "appid = 52b7f17b, work_dir = .";int aud_src = 0; /* from mic or file *//** See "iFlytek MSC Reference Manual"*/const char* session_begin_params ="sub = iat, domain = iat, language = zh_cn, ""accent = mandarin, sample_rate = 16000, ""result_type = plain, result_encoding = utf8";/* Login first. the 1st arg is username, the 2nd arg is password* just set them as NULL. the 3rd arg is login paramertes * */ret = MSPLogin(NULL, NULL, login_params);if (MSP_SUCCESS != ret)    {printf("MSPLogin failed , Error code %d.\n",ret);goto exit; // login fail, exit the program}while(rclcpp::ok()){// 语音识别唤醒     if(wakeupFlag){printf("Demo recognizing the speech from microphone\n");printf("Speak in 8 seconds\n");demo_mic(session_begin_params);printf("8 sec passed\n");wakeupFlag=0;}// 语音识别完成if(resultFlag){resultFlag=0;std_msgs::msg::String msg;msg.data = g_result;voiceWordsPub->publish(msg);}rclcpp::spin_some(node);loop_rate.sleep();count++;}
exit:MSPLogout(); // Logout...return 0;
}
  • cmakelist.txt 编译依赖问题
cmake_minimum_required(VERSION 3.8)
project(voice)if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")add_compile_options(-Wall -Wextra -Wpedantic)
endif()# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
include_directories(include)if(BUILD_TESTING)find_package(ament_lint_auto REQUIRED)# the following line skips the linter which checks for copyrights# comment the line when a copyright and license is added to all source filesset(ament_cmake_copyright_FOUND TRUE)# the following line skips cpplint (only works in a git repo)# comment the line when this package is in a git repo and when# a copyright and license is added to all source filesset(ament_cmake_cpplint_FOUND TRUE)ament_lint_auto_find_test_dependencies()
endif()ament_package()set(dependenciesrclcppstd_msgs
)add_executable(iat_publish src/iat_publish.cpp src/speech_recognizer.c src/linuxrec.c)
ament_target_dependencies(iat_publish ${dependencies})add_executable(tts_subscribe src/tts_subscribe.cpp)
ament_target_dependencies(tts_subscribe ${dependencies})target_link_libraries(iat_publish${PROJECT_SOURCE_DIR}libmsc.so -ldl -lpthread -lm -lrt -lasound
)target_link_libraries(tts_subscribe${PROJECT_SOURCE_DIR}libmsc.so -ldl -pthread
)
install(TARGETSiat_publishDESTINATION lib/${PROJECT_NAME}
)
install(TARGETStts_subscribeDESTINATION lib/${PROJECT_NAME}
)
  • sh: 1: play: not found问题
sudo apt-get install sox
sudo apt-get install sox libsox-fmt-all
play tts_sample.wav

ros2 for voice相关推荐

  1. Google Voice开始发送邀请函

    今天收到了Google Voice的邀请函,标题为"You've been invited to Google Voice". 最近关于Google Voice 的新闻不少,出于好 ...

  2. ROS2概述和实践入门

    ROS可以说是⽬前机器⼈相关开源社区最流⾏的项⽬之⼀,它是⼀个易⽤且完备的机器⼈开发框架.⽣态乃⾄社区,海量的机器⼈开源项⽬(涵盖感知.规划.控制.定位.SLAM和建图.可视化等⼏乎所有机器⼈领域)均 ...

  3. 它来了!ROS2从入门到精通:理论与实战

    ROS是什么? 随着人工智能技术的飞速发展与进步,机器人的智能化已经成为现代机器人发展的终极目标.机器人发展的速度在不断提升,应用范围也在不断拓展,例如自动驾驶.移动机器人.操作机器人.信息机器人等. ...

  4. AUTOVC: Zero-Shot Voice Style Transfer with Only Autoencoder Loss代码调试过程

    论文: AUTOVC: Zero-Shot Voice Style Transfer with Only Autoencoder Loss 代码实现参考:https://github.com/peis ...

  5. AUTOVC: Zero-Shot Voice Style Transfer with Only Autoencoder Loss笔记

    文章目录 网络结构 说话人编码器 内容编码器 解码器 声码器 实验 论文: AUTOVC: Zero-Shot Voice Style Transfer with Only Autoencoder L ...

  6. VOICE VOER IP(VoIP)理论(NP水平学的)

    VOICE VOER IP:承载在IP数据包中的语音信息 分组电话网络的优点: Mor efficient use of bandwidth and equipment Lower transmiss ...

  7. Microsoft Teams Voice语音落地系列-5 实战: Sonus语音网关配置

    上一节中我们在Teams上面用命令配置好了Voice Routing Policy并分配给用户,理论上这时他的Teams UI上面的拨号盘就会出现.同时我们也建立好了PSTN Gateway, 这样子 ...

  8. 物联网技术周报第 141 期: 使用 Alexa Voice 和 Raspberry Pi 构建图片识别应用

    新闻 \\ \\t <Ubuntu 16.04 LTS 已在英特尔 NUC 和物联网主板上获得认证>在全球拥有数百万用户的热门GNU/Linux发行版本--Ubuntu的背后公司Canon ...

  9. LTE voice centric和data centric

    转载自<https://www.cnblogs.com/himalaya/p/13227441.html> 终端发起attach或者TAU请求时,会携带UE_usage_setting参数 ...

最新文章

  1. xml中1字节的UTF-8序列的字节1无效([字符编码]Invalid byte 1 of 1-byte UTF-8 sequence终极解决方案)
  2. 最推荐的深度学习课程
  3. LDAP-GUI管理工具
  4. Linux内核参数的介绍
  5. mysql更新数据能回滚吗_MySQL数据回滚-误更新和删除时快速恢复
  6. Java 获取文件目录最终的修改时间
  7. python类概念是什么意思_python面向对象是什么意思?面向对象九大概念简介
  8. 1024程序员 | 我如何从零基础转行成为一个自信的前端
  9. 论文查重率这么高,是由什么原因造成的?
  10. 2005/2006/2007/2008/2009/2010/2012/2013/2014/2015/2016/2017/2018/2019/2020高德poi一级类别 二级类别 三级类别
  11. 操作系统面试知识点总结
  12. EXCEL复制可见单元格
  13. 可以免费文字识别app有哪些?有这3款app就能够实现提取文字自由
  14. php随机产生六位数密码
  15. idea实现打包springboot项目并且运行在cmd中
  16. Python个人项目2 --------青蛙旅行项目
  17. java web 蓝牙打印_android 蓝牙打印机示例
  18. Yii学习--使用Yii来建立博客
  19. C#-MSDN学习提高
  20. 如何为戴尔灵越15 5559加装内存条和固态硬盘

热门文章

  1. Python(24)python中的calendar模块(日历模块)
  2. mysql一行受影响是什么意思_行受影响 是什么意思
  3. ps暂存盘已满的解决办法
  4. HTML5表单元素拓展
  5. 未来社区系统整体解决方案
  6. [NJUST]19级上机考试题解
  7. 计算机体系结构期末复习
  8. 文件上传在Struts的Action检测文件类型
  9. 简述js原型链_简述js
  10. java基于微信小程序的社区后勤报修系统 uniapp 小程序