<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[在小强中使用语音识别和语音合成]]></title><description><![CDATA[<p dir="auto"><a href="https://www.bwbot.org/products/xiaoqiang-4-pro" target="_blank" rel="noopener noreferrer">小强主页</a></p>
<p dir="auto">为小强添加语音识别和语音合成功能，安装之后小强就能说会道了。当然首先要给小强添加话筒和喇叭。</p>
<p dir="auto">处理后端可以设置为科大迅飞语音或百度语音。也可以利用audio_capture实时的处理从话筒中收到的数据。</p>
<h2>安装，小强已经默认安装好了</h2>
<pre><code class="language-bash">cd [到你的工作空间的src文件夹中]
git clone https://gitee.com/BluewhaleRobot/xiaoqiang_tts
# 对于python3环境需要切换至python3分支
cd xiaoqiang_tts
git checkout python3
git clone https://gitee.com/BluewhaleRobot/xiaoqiang_audio
cd xiaoqiang_audio
git checkout noetic
cd ../..
catkin_make -DCATKIN_WHITELIST_PACKAGES="xiaoqiang_tts"
</code></pre>
<p dir="auto">程序使用的是我自己申请的百度和迅飞参数，最好自己再去百度和迅飞的官网申请一个。然后在launch文件中设置自己的appid，再catkin_make一下就可以了。</p>
<h2>使用</h2>
<h3>使用语音合成功能</h3>
<p dir="auto">启动百度语音合成</p>
<pre><code class="language-bash">roslaunch xiaoqiang_tts tts_baidu.launch
</code></pre>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:left">输入Topic</th>
<th style="text-align:left">消息类型</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">/xiaoqiang_tts/text</td>
<td style="text-align:left">std_msgs/String</td>
</tr>
</tbody>
<tbody>
<tr>
<td style="text-align:left">输出Topic</td>
<td style="text-align:left">消息类型</td>
</tr>
<tr>
<td style="text-align:left">:–</td>
<td style="text-align:left">:–</td>
</tr>
<tr>
<td style="text-align:left">/xiaoqiang_audio/audio</td>
<td style="text-align:left">audio_common_msgs/AudioData</td>
</tr>
</tbody>
</table>
<p dir="auto">发布消息，测试语音</p>
<pre><code class="language-bash">rostopic pub /xiaoqiang_tts/text std_msgs/String 测试一下语音合成 -1
</code></pre>
<p dir="auto">此时如果正常应该能够听到"测试一下语音合成"的声音</p>
<p dir="auto">启动科大迅飞语音合成</p>
<p dir="auto"><code>注意要先关闭百度tts节点</code></p>
<pre><code class="language-bash">roslaunch xiaoqiang_tts tts_xunfei.launch
</code></pre>
<p dir="auto">测试方法和上面一样。正常应该会听到合成的声音。</p>
<h3>使用语音识别功能</h3>
<p dir="auto">启动百度语音识别</p>
<pre><code class="language-bash">roslaunch xiaoqiang_tts asr_baidu.launch
</code></pre>
<p dir="auto">新开一个终端接收语音识别结果</p>
<pre><code class="language-bash">rostopic echo /xiaoqiang_tts/text
</code></pre>
<p dir="auto">现在可以开始说话了，程序会自动监听环境声音并进行分句。当你停止说话时会开始处理你的这一句的结果。</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:left">输入Topic</th>
<th style="text-align:left">消息类型</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">/xiaoqiang_audio/audio</td>
<td style="text-align:left">audio_common_msgs/AudioData</td>
</tr>
</tbody>
<tbody>
<tr>
<td style="text-align:left">输出Topic</td>
<td style="text-align:left">消息类型</td>
</tr>
<tr>
<td style="text-align:left">:–</td>
<td style="text-align:left">:–</td>
</tr>
<tr>
<td style="text-align:left">/xiaoqiang_tts/text</td>
<td style="text-align:left">std_msgs/String</td>
</tr>
</tbody>
</table>
<p dir="auto">启动迅飞语音识别</p>
<pre><code class="language-bash">roslaunch xiaoqiang_tts asr_xunfei.launch
</code></pre>
<p dir="auto">使用方法和上面的一样</p>
<h3>同时启动语音识别和语音合成</h3>
<p dir="auto">使用科大迅飞语音合成和语音识别</p>
<pre><code class="language-bash">roslaunch xiaoqiang_tts tts_xunfei.launch
roslaunch xiaoqiang_tts asr_xunfei.launch
</code></pre>
<p dir="auto">现在你说一句话机器人就会跟着你说一句话。</p>
<h3>和机器人对话</h3>
<pre><code class="language-bash">roslaunch xiaoqiang_nlp talk_bot.launch
</code></pre>
<p dir="auto">执行这个指令后机器人会和你对话交流，快和它说说话吧。</p>
<h3>参数说明</h3>
<p dir="auto">详细的参数说明请参照launch文件内的注释</p>
<p dir="auto"><a href="https://www.bwbot.org/products/xiaoqiang-4-pro" target="_blank" rel="noopener noreferrer">小强主页</a><br />
<a href="https://community.bwbot.org/topic/110" target="_blank" rel="noopener noreferrer">返回目录</a></p>
]]></description><link>http://community.bwbot.org/topic/492/在小强中使用语音识别和语音合成</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 19:13:18 GMT</lastBuildDate><atom:link href="http://community.bwbot.org/topic/492.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Jun 2018 03:28:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Fri, 16 Jul 2021 08:50:34 GMT]]></title><description><![CDATA[<p dir="auto">语音合成测试，运行成功，但是一直处于time.sleep中，出不来了，怎么办？</p>
]]></description><link>http://community.bwbot.org/post/16700</link><guid isPermaLink="true">http://community.bwbot.org/post/16700</guid><dc:creator><![CDATA[lpa]]></dc:creator><pubDate>Fri, 16 Jul 2021 08:50:34 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Fri, 16 Jul 2021 08:49:39 GMT]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1626425375250-3b399ca5-30a0-4101-acbf-ac5f332ab7e9-image.png" alt="3b399ca5-30a0-4101-acbf-ac5f332ab7e9-image.png" class=" img-responsive img-markdown" width="794" height="734" /></p>
]]></description><link>http://community.bwbot.org/post/16699</link><guid isPermaLink="true">http://community.bwbot.org/post/16699</guid><dc:creator><![CDATA[lpa]]></dc:creator><pubDate>Fri, 16 Jul 2021 08:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Thu, 19 Nov 2020 11:10:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1224">@林林林语</a> 你的依赖包没有安装</p>
<pre><code>sudo pip install baidu-aip
</code></pre>
]]></description><link>http://community.bwbot.org/post/4027</link><guid isPermaLink="true">http://community.bwbot.org/post/4027</guid><dc:creator><![CDATA[weijiz]]></dc:creator><pubDate>Thu, 19 Nov 2020 11:10:38 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Wed, 18 Nov 2020 09:12:25 GMT]]></title><description><![CDATA[<p dir="auto">你好，请问输入roslaunch xiaoqiang_tts asr_xunfei.launch指令会出现如下问题：ImportError: No module named aip<br />
[xiaoqiang_tts-2] process has died [pid 5287, exit code 1, cmd /home/cyl/catkin_ws/src/xiaoqiang_tts/src/xiaoqiang_tts_node.py ~audio:=/xiaoqiang_audio/audio __name:=xiaoqiang_tts __log:=/home/cyl/.ros/log/5cf44666-297d-11eb-bcc9-000c29c76404/xiaoqiang_tts-2.log].<br />
log file: /home/cyl/.ros/log/5cf44666-297d-11eb-bcc9-000c29c76404/xiaoqiang_tts-2*.log</p>
]]></description><link>http://community.bwbot.org/post/4026</link><guid isPermaLink="true">http://community.bwbot.org/post/4026</guid><dc:creator><![CDATA[林林林语]]></dc:creator><pubDate>Wed, 18 Nov 2020 09:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Tue, 01 Sep 2020 05:13:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1094">@joy</a> checkout到python3版本再编译</p>
]]></description><link>http://community.bwbot.org/post/3906</link><guid isPermaLink="true">http://community.bwbot.org/post/3906</guid><dc:creator><![CDATA[weijiz]]></dc:creator><pubDate>Tue, 01 Sep 2020 05:13:28 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Tue, 01 Sep 2020 02:26:11 GMT]]></title><description><![CDATA[<p dir="auto">ubuntu20.04 ros-noetic版本，python3.8，编译xiaoqiang_tts时报错：<br />
/home/lly/catkin_ws/src/xiaoqiang_tts/src/engines/xunfei/sdk/src/xunfei_tts.cpp:231:8: error: ‘StaticInit’ was not declared in this scope<br />
231 |   if (!StaticInit())<br />
请问这个该如何解决呢？貌似是python版本的问题</p>
]]></description><link>http://community.bwbot.org/post/3905</link><guid isPermaLink="true">http://community.bwbot.org/post/3905</guid><dc:creator><![CDATA[joy]]></dc:creator><pubDate>Tue, 01 Sep 2020 02:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Sun, 19 May 2019 02:25:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/7">@weijiz</a><br />
您好，运行roslaunch asr_xunfei.launch遇到这个错误该如何解决，感谢您<br />
File “/home/zhk2/catkin_ws/src/xiaoqiang_tts/src/xiaoqiang_asr_node.py”, line 30, in<br />
from engines.baidu_tts import BaiduTTS as bd_client<br />
File “/home/zhk2/catkin_ws/src/xiaoqiang_tts/src/engines/baidu_tts.py”, line 29, in<br />
from aip import AipSpeech<br />
File “/usr/local/lib/python2.7/dist-packages/aip/init.py”, line 6, in<br />
from .ocr import AipOcr<br />
File “/usr/local/lib/python2.7/dist-packages/aip/ocr.py”, line 12, in<br />
from .base import AipBase<br />
File “/usr/local/lib/python2.7/dist-packages/aip/base.py”, line 14, in<br />
requests.packages.urllib3.disable_warnings()<br />
AttributeError: ‘module’ object has no attribute ‘packages’<br />
[xiaoqiang_asr-2] process has died [pid 6074, exit code 1, cmd /home/zhk2/catkin_ws/src/xiaoqiang_tts/src/xiaoqiang_asr_node.py ~audio:=/audio/audio ~text:=/xiaoqiang_tts/text ~audio_status:=/xiaoqiang_audio/audio_status __name:=xiaoqiang_asr __log:=/home/zhk2/.ros/log/dc555cb2-79dc-11e9-a2e6-f4ec3802170a/xiaoqiang_asr-2.log].<br />
log file: /home/zhk2/.ros/log/dc555cb2-79dc-11e9-a2e6-f4ec3802170a/xiaoqiang_asr-2*.log</p>
]]></description><link>http://community.bwbot.org/post/1263</link><guid isPermaLink="true">http://community.bwbot.org/post/1263</guid><dc:creator><![CDATA[zhk15951]]></dc:creator><pubDate>Sun, 19 May 2019 02:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Mon, 13 May 2019 07:40:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/7">@weijiz</a> 谢谢</p>
]]></description><link>http://community.bwbot.org/post/1255</link><guid isPermaLink="true">http://community.bwbot.org/post/1255</guid><dc:creator><![CDATA[robot0612]]></dc:creator><pubDate>Mon, 13 May 2019 07:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Mon, 13 May 2019 00:58:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/814">@robot0612</a> 在 <a href="/post/1248">在小强中使用语音识别和语音合成</a> 中说：</p>
<blockquote></blockquote>
<p dir="auto">更新代码到最新版，这个问题已经<a href="https://github.com/BluewhaleRobot/xiaoqiang_tts/commit/5b1dcbd1d5f50ab2c4155a32102399e2fe0bc982" target="_blank" rel="noopener noreferrer">修复</a>了</p>
]]></description><link>http://community.bwbot.org/post/1251</link><guid isPermaLink="true">http://community.bwbot.org/post/1251</guid><dc:creator><![CDATA[weijiz]]></dc:creator><pubDate>Mon, 13 May 2019 00:58:16 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Sun, 12 May 2019 13:55:43 GMT]]></title><description><![CDATA[<p dir="auto">语音识别，内容过长，比如讲故事，就会报错：可有办法解决<br />
<img src="/assets/uploads/files/1557669323855-d4917633-f782-4612-a4df-888c99f10091-image.png" alt="d4917633-f782-4612-a4df-888c99f10091-image.png" class=" img-responsive img-markdown" width="970" height="690" /></p>
]]></description><link>http://community.bwbot.org/post/1248</link><guid isPermaLink="true">http://community.bwbot.org/post/1248</guid><dc:creator><![CDATA[robot0612]]></dc:creator><pubDate>Sun, 12 May 2019 13:55:43 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Sat, 09 Mar 2019 00:47:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/814">@robot0612</a> 这个错误可以忽略，继续进行</p>
]]></description><link>http://community.bwbot.org/post/1112</link><guid isPermaLink="true">http://community.bwbot.org/post/1112</guid><dc:creator><![CDATA[weijiz]]></dc:creator><pubDate>Sat, 09 Mar 2019 00:47:14 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Fri, 08 Mar 2019 16:26:53 GMT]]></title><description><![CDATA[<p dir="auto">已经运行了这个 rosdep install xiaoqiang_audio<br />
#All required rosdeps installed successfully</p>
]]></description><link>http://community.bwbot.org/post/1111</link><guid isPermaLink="true">http://community.bwbot.org/post/1111</guid><dc:creator><![CDATA[robot0612]]></dc:creator><pubDate>Fri, 08 Mar 2019 16:26:53 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Fri, 08 Mar 2019 16:26:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/7">@weijiz</a> 运行rosdep install xiaoqiang_tts  时提示<br />
ERROR: the following packages/stacks could not have their rosdep keys resolved<br />
to system dependencies:<br />
xiaoqiang_tts: Cannot locate rosdep definition for [xiaoqiang_audio]</p>
]]></description><link>http://community.bwbot.org/post/1110</link><guid isPermaLink="true">http://community.bwbot.org/post/1110</guid><dc:creator><![CDATA[robot0612]]></dc:creator><pubDate>Fri, 08 Mar 2019 16:26:24 GMT</pubDate></item><item><title><![CDATA[Reply to 在小强中使用语音识别和语音合成 on Sat, 30 Jun 2018 09:03:00 GMT]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1530349378908-1530349342-1.jpg" alt="0_1530349379643_1530349342(1).jpg" class=" img-responsive img-markdown" width="738" height="81" /></p>
]]></description><link>http://community.bwbot.org/post/675</link><guid isPermaLink="true">http://community.bwbot.org/post/675</guid><dc:creator><![CDATA[Yangoogle]]></dc:creator><pubDate>Sat, 30 Jun 2018 09:03:00 GMT</pubDate></item></channel></rss>