Widora-neo应用百度在线语音合成和识别



  • 在widora-neo上试用了一下在线百度语音合成功能,发现它的中文发音非常不错,音频返回也很快,读文章的时候基本觉察不到间隙。
    现将过程记录下来供大家参考,官方的帮助文档在这里:http://yuyin.baidu.com/file/download/660

    1. 申请百度语音帐号
    http://yuyin.baidu.com/ 申请帐号,并创建一个语音合成的应用, 得到API Key。
    0_1484004112338_upload-ac180cf0-9dac-4c0a-860c-fc5b87eac208

    2. 在widora-neo上安装curl
    opkg update 然后 opkeg install curl

    3. 获取ACCESS_TOKEN
    3.1 用curl向baidu发送请求, 标示处替换成上面获得的API Key 和 Secret Key:
    0_1484005343370_upload-7448e9a2-67ae-4011-924d-33c95e3c370e
    3.2 返回得到ACCESS_TOKE
    0_1484006657355_upload-dcac6291-7440-4a91-8e95-d0a6fb074c2c

    注意:ACCESS_TOKEN每个月需要重新获取.

    4. 发送中文获取语音mp3文件
    现在用curl发送请求就可以返回mp3文件了,当然后面要带上你的access_token. 其中cuid我用了MAC地址.
    0_1484006949035_upload-25ea6a47-0d03-4833-a30e-330095166b31

    5.制作发音脚本
    5.1 建一个fifo管道,mkfifo -m 777 /home/mp3fifo
    5.2 建立一个sh脚本,命名成getvoice,内容如下:
    0_1484007470916_upload-a3bf2bf0-b3d5-4527-b924-25f48f8c1eeb
    5.3 赋予权限 chmod 755 getvoice
    运行一下:
    ./getvoice 你坐得太久了!休息一下,做做瑜珈吧。。。哈

    好了,这下可以展开想象空间,在你的代码里到处加上语音吧!!!!

    6.阅读文章
    复习linux脚本的时候到了! 有了上面的getvoice,其实也不难了。就是用sed循环提取文章句段,然后调用getvoice而已。
    如果你的文件放在/home/book1.txt, 那么可以这样写个脚本readbook:
    book=${1}
    j=1
    pn=sed -n '$=' ${book}
    while [ $j -le $pn ]
    do
    words=sed -n "$j,$(($j+2))p" ${book}
    echo ${words}
    getvoice ${words}
    j=$(($j+3))
    done

    然后执行:readbook /home/book1.txt 就开始阅读了。
    是不是很好玩啊!



  • 想问问你发贴关于mraa控制pwm的问题,想知道利用eclipse交叉编译时总是报错如何解决,谢谢!我的QQ:6705641



  • ========== 百度语音识别 =============

    1. 在百度语音账号中创建一个语音识别应用,得到相应的ID,API Key,Secret Key.

    2. 在widora-neo上安装php5:
      opkg install php5 php5-cgi php5-mod-curl php5-mod-json

    3. 参照上面的步骤,获取语音识别应用的access_toke

    4. 参考官方的sample2.php文件,做一些小修改,制作一个up.php文件如下:

    其中: cuid,apiKey,secretKey,token分别填入你自己的AppID,API Key,Secret Key,AccessToken.

    1. 运行alsamixer, 按F4键 将Capture 和 ADC PCM 项调到足够大。不然录音音量太小的话,也会造成无法识别。
      0_1484537086797_upload-ebed4fd6-d3c2-4319-b467-d1b22666daa2

    2. 录制一段语音: arecord -r 8000 -f S16_LE test.wav
      注意格式和API要求一致, test.wav文件名和up.php中一致。

    3. 运行命令:php-cgi up.php
      php会发送wav文件到百度API, 并返回识别出的语句。
      0_1484537154215_upload-a048d80b-8f5e-4432-83c7-161191b0b1f6



  • 用curl或php下载RSS新闻提要,用sed抽取中文消息。可以很方便地做成一个新闻提要播报机,定时播报。



  • widora-neo的新闻提要播报效果 0_1487031120174_widora新闻提要播报 NK-news.mp3



  • 用了一段时间的百度语言合成新闻播报,发现效果不错,分享给大家参考。
    主要用了2个脚本文件,一个getmp3,另外一个nknews,

    getmp3脚本:根据输入的中文来取得百度语音合成的mp3文件,并保存到临时文件/tmp/getmp3.mp3。XXX请应用自己的百度语音合成帐号。

    #!/bin/sh
    RET=fail
    while [[ $RET == fail ]]
    do
    curl --max-time 20 --retry 0 -G "http://tsn.baidu.com/text2audio?tex=${*}lan=zh&pit=5&cuid=XX:XX:XX:XX:XX:XX&ctp=1&per=0&tok=XXXXXXXXXXXXXXXXXXXXXXX" > /tmp/getmp3.mp3 && RET=OK || RET=fail
    done

    nknews脚本: 主要是抓取http://cn.nikkei.com/rss.html中文新闻条目,并调用getmp3转换成mp3后合成一个文件,最后用madplay或者mplayer进行播放。

    #!/bin/sh

    #------- 抓取中文新闻条目 保存到 /tmp/newstitle-------------
    curl -s http://cn.nikkei.com/rss.html | grep "CDATA|title" | sed 's//新闻提要/;s/</title>//;s/^.<em>[CDATA[//;s/]]>.</em>$//;s/[[:space:]]//g' > /tmp/newstitle</p> <p>book=/tmp/newstitle<br /> j=1</p> <p>#-------- 取得新闻条目总数<br /> pn=<code>sed -n '$=' ${book}</code><br /> #-------- 创建临时文件<br /> rm -f /tmp/nk.mp3<br /> touch /tmp/nk.mp3</p> <p>#------- 逐条用getmp3脚本百度语言合成<br /> while [ $j -le $pn ]<br /> do<br /> words=<code>sed -n "$j,$(($j))p" ${book}</code><br /> echo j=$j ${words}<br /> /home/getmp3 ${words}<br /> #-------- 逐条合并到nk.mp3<br /> cat /tmp/getmp3.mp3 >> /tmp/nk.mp3<br /> wait<br /> j=$(($j+1))<br /> #sleep 5<br /> done</p> <p>#-------- 用madplay 或 mplayer 播放<br /> madplay /tmp/nk.mp3<br /> #mplayer /tmp/nk.mp3</p> </div> <div class="clearfix post-footer"> <small class="pull-right"> <span class="post-tools"> <a component="post/reply" href="#" class="no-select hidden">Reply</a> <a component="post/quote" href="#" class="no-select hidden">Quote</a> </span> <span component="post/tools" class="dropdown moderator-tools bottom-sheet "> <a href="#" data-toggle="dropdown"><i class="fa fa-fw fa-ellipsis-v"></i></a> <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul> </span> </small> <a component="post/reply-count" href="#" class="threaded-replies no-select hidden"> <span component="post/reply-count/avatars" class="avatars "> </span> <span class="replies-count" component="post/reply-count/text" data-replies="0">1 Reply</span> <span class="replies-last hidden-xs">Last reply <span class="timeago" title=""></span></span> <i class="fa fa-fw fa-chevron-right" component="post/replies/open"></i> <i class="fa fa-fw fa-chevron-down hidden" component="post/replies/close"></i> <i class="fa fa-fw fa-spin fa-spinner hidden" component="post/replies/loading"></i> </a> </div> <hr /> </li> <li component="post" class="" data-index="3" data-pid="701" data-uid="255" data-timestamp="1498631306681" data-username="郭大路" data-userslug="郭大路" itemscope itemtype="http://schema.org/Comment"> <a component="post/anchor" data-index="3" id="3"></a> <meta itemprop="datePublished" content="2017-06-28T06:28:26.681Z"> <meta itemprop="dateModified" content=""> <div class="clearfix post-header"> <div class="icon pull-left"> <a href="/user/郭大路"> <div component="user/picture" data-uid="255" class="user-icon" style="background-color: #827717;">郭</div> <i component="user/status" class="fa fa-circle status offline" title="Offline"></i> </a> </div> <small class="pull-left"> <strong> <a href="/user/郭大路" itemprop="author" data-username="郭大路" data-uid="255">郭大路</a> </strong> <span class="visible-xs-inline-block visible-sm-inline-block visible-md-inline-block visible-lg-inline-block"> <a class="permalink" href="/post/701"><span class="timeago" title="2017-06-28T06:28:26.681Z"></span></a> <i component="post/edit-indicator" class="fa fa-pencil-square edit-icon hidden"></i> <small data-editor="" component="post/editor" class="hidden">last edited by <span class="timeago" title=""></span></small> <span> </span> </span> <span class="bookmarked"><i class="fa fa-bookmark-o"></i></span> </small> </div> <br /> <div class="content" component="post/content" itemprop="text"> <p>创意非常不错!!!<br /> 就是这个没感情的声音听久了人会疯掉</p> </div> <div class="clearfix post-footer"> <small class="pull-right"> <span class="post-tools"> <a component="post/reply" href="#" class="no-select hidden">Reply</a> <a component="post/quote" href="#" class="no-select hidden">Quote</a> </span> <span component="post/tools" class="dropdown moderator-tools bottom-sheet "> <a href="#" data-toggle="dropdown"><i class="fa fa-fw fa-ellipsis-v"></i></a> <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul> </span> </small> <a component="post/reply-count" href="#" class="threaded-replies no-select "> <span component="post/reply-count/avatars" class="avatars "> <span><img component="user/picture" data-uid="14" title="midas-zhou" class="avatar" src="/uploads/profile/14-profileimg.png" itemprop="image" /></span> </span> <span class="replies-count" component="post/reply-count/text" data-replies="1">1 Reply</span> <span class="replies-last hidden-xs">Last reply <span class="timeago" title="2017-06-28T11:51:14.245Z"></span></span> <i class="fa fa-fw fa-chevron-right" component="post/replies/open"></i> <i class="fa fa-fw fa-chevron-down hidden" component="post/replies/close"></i> <i class="fa fa-fw fa-spin fa-spinner hidden" component="post/replies/loading"></i> </a> </div> <hr /> </li> <li component="post" class="" data-index="2" data-pid="704" data-uid="14" data-timestamp="1498650674245" data-username="midas-zhou" data-userslug="midas-zhou" itemscope itemtype="http://schema.org/Comment"> <a component="post/anchor" data-index="2" id="2"></a> <meta itemprop="datePublished" content="2017-06-28T11:51:14.245Z"> <meta itemprop="dateModified" content=""> <div class="clearfix post-header"> <div class="icon pull-left"> <a href="/user/midas-zhou"> <img component="user/picture" data-uid="14" src="/uploads/profile/14-profileimg.png" align="left" itemprop="image" /> <i component="user/status" class="fa fa-circle status offline" title="Offline"></i> </a> </div> <small class="pull-left"> <strong> <a href="/user/midas-zhou" itemprop="author" data-username="midas-zhou" data-uid="14">midas-zhou</a> </strong> <span class="visible-xs-inline-block visible-sm-inline-block visible-md-inline-block visible-lg-inline-block"> <a class="permalink" href="/post/704"><span class="timeago" title="2017-06-28T11:51:14.245Z"></span></a> <i component="post/edit-indicator" class="fa fa-pencil-square edit-icon hidden"></i> <small data-editor="" component="post/editor" class="hidden">last edited by <span class="timeago" title=""></span></small> <a component="post/parent" class="btn btn-xs btn-default hidden-xs" data-topid="701" href="/post/701"><i class="fa fa-reply"></i> @郭大路</a> <span> </span> </span> <span class="bookmarked"><i class="fa fa-bookmark-o"></i></span> </small> </div> <br /> <div class="content" component="post/content" itemprop="text"> <p><a class="plugin-mentions-user plugin-mentions-a" href="https://widora.io/uid/255">@郭大路</a> 这倒是,有个新闻点播源就好了。</p> </div> <div class="clearfix post-footer"> <small class="pull-right"> <span class="post-tools"> <a component="post/reply" href="#" class="no-select hidden">Reply</a> <a component="post/quote" href="#" class="no-select hidden">Quote</a> </span> <span component="post/tools" class="dropdown moderator-tools bottom-sheet "> <a href="#" data-toggle="dropdown"><i class="fa fa-fw fa-ellipsis-v"></i></a> <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul> </span> </small> <a component="post/reply-count" href="#" class="threaded-replies no-select hidden"> <span component="post/reply-count/avatars" class="avatars "> </span> <span class="replies-count" component="post/reply-count/text" data-replies="0">1 Reply</span> <span class="replies-last hidden-xs">Last reply <span class="timeago" title=""></span></span> <i class="fa fa-fw fa-chevron-right" component="post/replies/open"></i> <i class="fa fa-fw fa-chevron-down hidden" component="post/replies/close"></i> <i class="fa fa-fw fa-spin fa-spinner hidden" component="post/replies/loading"></i> </a> </div> <hr /> </li> <li component="post" class="" data-index="1" data-pid="711" data-uid="188" data-timestamp="1498898820304" data-username="greeglang" data-userslug="greeglang" itemscope itemtype="http://schema.org/Comment"> <a component="post/anchor" data-index="1" id="1"></a> <meta itemprop="datePublished" content="2017-07-01T08:47:00.304Z"> <meta itemprop="dateModified" content=""> <div class="clearfix post-header"> <div class="icon pull-left"> <a href="/user/greeglang"> <div component="user/picture" data-uid="188" class="user-icon" style="background-color: #9c27b0;">G</div> <i component="user/status" class="fa fa-circle status offline" title="Offline"></i> </a> </div> <small class="pull-left"> <strong> <a href="/user/greeglang" itemprop="author" data-username="greeglang" data-uid="188">greeglang</a> </strong> <span class="visible-xs-inline-block visible-sm-inline-block visible-md-inline-block visible-lg-inline-block"> <a class="permalink" href="/post/711"><span class="timeago" title="2017-07-01T08:47:00.304Z"></span></a> <i component="post/edit-indicator" class="fa fa-pencil-square edit-icon hidden"></i> <small data-editor="" component="post/editor" class="hidden">last edited by <span class="timeago" title=""></span></small> <span> </span> </span> <span class="bookmarked"><i class="fa fa-bookmark-o"></i></span> </small> </div> <br /> <div class="content" component="post/content" itemprop="text"> <p>具备商用价值就好了</p> </div> <div class="clearfix post-footer"> <small class="pull-right"> <span class="post-tools"> <a component="post/reply" href="#" class="no-select hidden">Reply</a> <a component="post/quote" href="#" class="no-select hidden">Quote</a> </span> <span component="post/tools" class="dropdown moderator-tools bottom-sheet "> <a href="#" data-toggle="dropdown"><i class="fa fa-fw fa-ellipsis-v"></i></a> <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul> </span> </small> <a component="post/reply-count" href="#" class="threaded-replies no-select hidden"> <span component="post/reply-count/avatars" class="avatars "> </span> <span class="replies-count" component="post/reply-count/text" data-replies="0">1 Reply</span> <span class="replies-last hidden-xs">Last reply <span class="timeago" title=""></span></span> <i class="fa fa-fw fa-chevron-right" component="post/replies/open"></i> <i class="fa fa-fw fa-chevron-down hidden" component="post/replies/close"></i> <i class="fa fa-fw fa-spin fa-spinner hidden" component="post/replies/loading"></i> </a> </div> <hr /> </li> </ul> <div class="post-bar"> <div class="clearfix"> <div class="tags pull-left"> </div> <div component="topic/browsing-users"> </div> <div class="topic-main-buttons pull-right"> <span class="loading-indicator btn pull-left hidden" done="0"> <span class="hidden-xs">Loading More Posts</span> <i class="fa fa-refresh fa-spin"></i> </span> <div class="stats hidden-xs"> <span component="topic/post-count" class="human-readable-number" title="9">9</span><br /> <small>Posts</small> </div> <div class="stats hidden-xs"> <span class="human-readable-number" title="9547">9547</span><br /> <small>Views</small> </div> <div component="topic/reply/container" class="btn-group action-bar bottom-sheet hidden"> <a href="/compose?tid=78&title=Widora-neo应用百度在线语音合成和识别" class="btn btn-primary" component="topic/reply" data-ajaxify="false" role="button"><i class="fa fa-reply visible-xs-inline"></i><span class="visible-sm-inline visible-md-inline visible-lg-inline"> Reply</span></a> <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu pull-right" role="menu"> <li><a href="#" component="topic/reply-as-topic">Reply as topic</a></li> </ul> </div> <a component="topic/reply/guest" href="/login" class="btn btn-primary">Log in to reply</a> <div class="pull-right">  </div> </div> </div> <hr/> </div> <div component="pagination" class="text-center pagination-container hidden"> <ul class="pagination hidden-xs"> <li class="previous pull-left disabled"> <a href="?" data-page="1"><i class="fa fa-chevron-left"></i> </a> </li> <li class="next pull-right disabled"> <a href="?" data-page="1"> <i class="fa fa-chevron-right"></i></a> </li> </ul> <ul class="pagination hidden-sm hidden-md hidden-lg"> <li class="first disabled"> <a href="?page=1" data-page="1"><i class="fa fa-fast-backward"></i> </a> </li> <li class="previous disabled"> <a href="?" data-page="1"><i class="fa fa-chevron-left"></i> </a> </li> <li component="pagination/select-page" class="page select-page"> <a href="#">1 / 1</a> </li> <li class="next disabled"> <a href="?" data-page="1"> <i class="fa fa-chevron-right"></i></a> </li> <li class="last disabled"> <a href="?page=1" data-page="1"><i class="fa fa-fast-forward"></i> </a> </li> </ul> </div> <div class="navigator-thumb text-center hidden"> <strong class="text"></strong><br/> <span class="time"></span> </div> <div class="visible-xs visible-sm pagination-block text-center"> <div class="progress-bar"></div> <div class="wrapper"> <i class="fa fa-2x fa-angle-double-up pointer fa-fw pagetop"></i> <i class="fa fa-2x fa-angle-up pointer fa-fw pageup"></i> <span class="pagination-text"></span> <i class="fa fa-2x fa-angle-down pointer fa-fw pagedown"></i> <i class="fa fa-2x fa-angle-double-down pointer fa-fw pagebottom"></i> </div> </div> </div> <div widget-area="sidebar" class="col-lg-3 col-sm-12 hidden"> </div> </div> <div widget-area="footer"> <footer id="footer" class="container footer"> <div class="copyright"> ©widora inc. 2017-2019 </div> </footer> </div> <script id="ajaxify-data" type="application/json">{"tid":78,"uid":14,"cid":28,"mainPid":162,"title":"Widora-neo应用百度在线语音合成和识别","slug":"78/widora-neo应用百度在线语音合成和识别","timestamp":1484003949512,"lastposttime":1498898820304,"postcount":9,"viewcount":9547,"locked":0,"deleted":0,"pinned":0,"thumb":"","teaserPid":"711","downvotes":0,"upvotes":0,"oldCid":"15","titleRaw":"Widora-neo应用百度在线语音合成和识别","timestampISO":"2017-01-09T23:19:09.512Z","lastposttimeISO":"2017-07-01T08:47:00.304Z","votes":0,"tags":[],"posts":[{"pid":162,"uid":14,"tid":78,"content":"<p>在widora-neo上试用了一下在线百度语音合成功能,发现它的中文发音非常不错,音频返回也很快,读文章的时候基本觉察不到间隙。<br />\n现将过程记录下来供大家参考,官方的帮助文档在这里:<a href=\"http://yuyin.baidu.com/file/download/660\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">http://yuyin.baidu.com/file/download/660<\/a><\/p>\n<p><strong><strong>1. 申请百度语音帐号<\/strong><\/strong><br />\n到 <a href=\"http://yuyin.baidu.com/\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">http://yuyin.baidu.com/<\/a> 申请帐号,并创建一个语音合成的应用, 得到API Key。<br />\n<img src=\"/uploads/files/1484004044775-upload-ac180cf0-9dac-4c0a-860c-fc5b87eac208-resized.png\" alt=\"0_1484004112338_upload-ac180cf0-9dac-4c0a-860c-fc5b87eac208\" class=\"img-responsive img-markdown\" /><\/p>\n<p><strong>2. 在widora-neo上安装curl<\/strong><br />\nopkg update 然后 opkeg install curl<\/p>\n<p><strong>3. 获取ACCESS_TOKEN<\/strong><br />\n3.1 用curl向baidu发送请求, 标示处替换成上面获得的API Key 和 Secret Key:<br />\n<img src=\"/uploads/files/1484005265973-upload-7448e9a2-67ae-4011-924d-33c95e3c370e-resized.png\" alt=\"0_1484005343370_upload-7448e9a2-67ae-4011-924d-33c95e3c370e\" class=\"img-responsive img-markdown\" /><br />\n3.2 返回得到ACCESS_TOKE<br />\n<img src=\"/uploads/files/1484006578484-upload-dcac6291-7440-4a91-8e95-d0a6fb074c2c-resized.png\" alt=\"0_1484006657355_upload-dcac6291-7440-4a91-8e95-d0a6fb074c2c\" class=\"img-responsive img-markdown\" /><\/p>\n<p><strong>注意:ACCESS_TOKEN每个月需要重新获取.<\/strong><\/p>\n<p><strong>4. 发送中文获取语音mp3文件<\/strong><br />\n现在用curl发送请求就可以返回mp3文件了,当然后面要带上你的access_token. 其中cuid我用了MAC地址.<br />\n<img src=\"/uploads/files/1484006870123-upload-25ea6a47-0d03-4833-a30e-330095166b31-resized.png\" alt=\"0_1484006949035_upload-25ea6a47-0d03-4833-a30e-330095166b31\" class=\"img-responsive img-markdown\" /><\/p>\n<p><strong><strong>5.制作发音脚本<\/strong><\/strong><br />\n5.1 建一个fifo管道,mkfifo -m 777 /home/mp3fifo<br />\n5.2 建立一个sh脚本,命名成getvoice,内容如下:<br />\n<img src=\"/uploads/files/1484007391698-upload-a3bf2bf0-b3d5-4527-b924-25f48f8c1eeb-resized.png\" alt=\"0_1484007470916_upload-a3bf2bf0-b3d5-4527-b924-25f48f8c1eeb\" class=\"img-responsive img-markdown\" /><br />\n5.3 赋予权限 chmod 755 getvoice<br />\n运行一下:<br />\n./getvoice 你坐得太久了!休息一下,做做瑜珈吧。。。哈<\/p>\n<p><strong>好了,这下可以展开想象空间,在你的代码里到处加上语音吧!!!!<\/strong><\/p>\n<p><strong><strong>6.阅读文章<\/strong><\/strong><br />\n复习linux脚本的时候到了! 有了上面的getvoice,其实也不难了。就是用sed循环提取文章句段,然后调用getvoice而已。<br />\n如果你的文件放在/home/book1.txt, 那么可以这样写个脚本readbook:<br />\nbook=${1}<br />\nj=1<br />\npn=<code>sed -n '$=' ${book}<\/code><br />\nwhile [ $j -le $pn ]<br />\ndo<br />\nwords=<code>sed -n "$j,$(($j+2))p" ${book}<\/code><br />\necho ${words}<br />\ngetvoice ${words}<br />\nj=$(($j+3))<br />\ndone<\/p>\n<p>然后执行:readbook /home/book1.txt 就开始阅读了。<br />\n是不是很好玩啊!<\/p>\n","timestamp":1484003949512,"deleted":0,"edited":1486600567436,"editor":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou"},"upvotes":0,"downvotes":0,"deleterUid":0,"votes":0,"timestampISO":"2017-01-09T23:19:09.512Z","editedISO":"2017-02-09T00:36:07.436Z","index":0,"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":163,"uid":97,"tid":78,"content":"<p>想问问你发贴关于mraa控制pwm的问题,想知道利用eclipse交叉编译时总是报错如何解决,谢谢!我的QQ:6705641<\/p>\n","timestamp":1484004165953,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-01-09T23:22:45.953Z","editedISO":"","index":8,"user":{"uid":97,"username":"dahuzhi_cn","userslug":"dahuzhi_cn","reputation":0,"postcount":1,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1485151524561,"groupTitle":null,"groupTitleArray":[],"icon:text":"D","icon:bgColor":"#673ab7","lastonlineISO":"2017-01-23T06:05:24.561Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":170,"uid":14,"tid":78,"content":"<p>========== 百度语音识别 =============<\/p>\n<ol>\n<li>\n<p>在百度语音账号中创建一个语音识别应用,得到相应的ID,API Key,Secret Key.<\/p>\n<\/li>\n<li>\n<p>在widora-neo上安装php5:<br />\nopkg install php5 php5-cgi php5-mod-curl php5-mod-json<\/p>\n<\/li>\n<li>\n<p>参照上面的步骤,获取语音识别应用的access_toke<\/p>\n<\/li>\n<li>\n<p>参考官方的sample2.php文件,做一些小修改,制作一个up.php文件如下:<\/p>\n<\/li>\n<\/ol>\n<?php\ndefine('AUDIO_FILE', \"/tmp/test.wav\");\n//put your params here\n$cuid = \" xxxxxxx\";\n$apiKey = \"xxxxxxxxxxxxx\";\n$secretKey = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\";\n$token =\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n$url = \"http://vop.baidu.com/server_api?cuid=\".$cuid.\"&token=\".$token;\n//$url = $url.\"&lan=zh\";\n$audio = file_get_contents(AUDIO_FILE);\n$content_len = \"Content-Length: \".strlen($audio);\n$header = array ($content_len,'Content-Type: audio/wav; rate=8000',);\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, $url);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $header);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);\ncurl_setopt($ch, CURLOPT_TIMEOUT, 30);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $audio);\n$response = curl_exec($ch);\nif(curl_errno($ch))\n{\n print curl_error($ch);\n}\ncurl_close($ch);\necho $response;\n$response = json_decode($response, true);\nvar_dump($response);\n?>\n<p><strong>其中: cuid,apiKey,secretKey,token分别填入你自己的AppID,API Key,Secret Key,AccessToken.<\/strong><\/p>\n<ol start=\"5\">\n<li>\n<p>运行alsamixer, 按F4键 将Capture 和 ADC PCM 项调到足够大。不然录音音量太小的话,也会造成无法识别。<br />\n<img src=\"/uploads/files/1484537000298-upload-ebed4fd6-d3c2-4319-b467-d1b22666daa2-resized.png\" alt=\"0_1484537086797_upload-ebed4fd6-d3c2-4319-b467-d1b22666daa2\" class=\"img-responsive img-markdown\" /><\/p>\n<\/li>\n<li>\n<p>录制一段语音: arecord -r 8000 -f S16_LE test.wav<br />\n注意格式和API要求一致, test.wav文件名和up.php中一致。<\/p>\n<\/li>\n<li>\n<p>运行命令:php-cgi up.php<br />\nphp会发送wav文件到百度API, 并返回识别出的语句。<br />\n<img src=\"/uploads/files/1484537067026-upload-a048d80b-8f5e-4432-83c7-161191b0b1f6.png\" alt=\"0_1484537154215_upload-a048d80b-8f5e-4432-83c7-161191b0b1f6\" class=\"img-responsive img-markdown\" /><\/p>\n<\/li>\n<\/ol>\n","timestamp":1484535945492,"deleted":0,"edited":1491020603837,"editor":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou"},"upvotes":0,"downvotes":0,"deleterUid":0,"votes":0,"timestampISO":"2017-01-16T03:05:45.492Z","editedISO":"2017-04-01T04:23:23.837Z","index":7,"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":172,"uid":14,"tid":78,"content":"<p>用curl或php下载RSS新闻提要,用sed抽取中文消息。可以很方便地做成一个新闻提要播报机,定时播报。<\/p>\n","timestamp":1484869049113,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-01-19T23:37:29.113Z","editedISO":"","index":6,"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":189,"uid":14,"tid":78,"content":"<p>widora-neo的新闻提要播报效果 <a href=\"/uploads/files/1487031025070-widora%E6%96%B0%E9%97%BB%E6%8F%90%E8%A6%81%E6%92%AD%E6%8A%A5-nk-news.undefined\">0_1487031120174_widora新闻提要播报 NK-news.mp3<\/a><\/p>\n","timestamp":1487031026673,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-02-14T00:10:26.673Z","editedISO":"","index":5,"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":699,"uid":14,"tid":78,"content":"<p>用了一段时间的百度语言合成新闻播报,发现效果不错,分享给大家参考。<br />\n主要用了2个脚本文件,一个getmp3,另外一个nknews,<\/p>\n<p>getmp3脚本:根据输入的中文来取得百度语音合成的mp3文件,并保存到临时文件/tmp/getmp3.mp3。XXX请应用自己的百度语音合成帐号。<\/p>\n<p>#!/bin/sh<br />\nRET=fail<br />\nwhile [[ $RET == fail ]]<br />\ndo<br />\ncurl --max-time 20 --retry 0 -G "<a href=\"http://tsn.baidu.com/text2audio?tex=$%7B*%7Dlan=zh&pit=5&cuid=XX:XX:XX:XX:XX:XX&ctp=1&per=0&tok=XXXXXXXXXXXXXXXXXXXXXXX\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">http://tsn.baidu.com/text2audio?tex=${*}lan=zh&pit=5&cuid=XX:XX:XX:XX:XX:XX&ctp=1&per=0&tok=XXXXXXXXXXXXXXXXXXXXXXX<\/a>" > /tmp/getmp3.mp3 && RET=OK || RET=fail<br />\ndone<\/p>\n<p>nknews脚本: 主要是抓取http://cn.nikkei.com/rss.html中文新闻条目,并调用getmp3转换成mp3后合成一个文件,最后用madplay或者mplayer进行播放。<\/p>\n<p>#!/bin/sh<\/p>\n<p>#------- 抓取中文新闻条目 保存到 /tmp/newstitle-------------<br />\ncurl -s <a href=\"http://cn.nikkei.com/rss.html\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">http://cn.nikkei.com/rss.html<\/a> | grep "CDATA|title" | sed 's/<title>/新闻提要/;s/</title>//;s/^.<em>[CDATA[//;s/]]>.<\/em>$//;s/[[:space:]]//g' > /tmp/newstitle<\/p>\n<p>book=/tmp/newstitle<br />\nj=1<\/p>\n<p>#-------- 取得新闻条目总数<br />\npn=<code>sed -n '$=' ${book}<\/code><br />\n#-------- 创建临时文件<br />\nrm -f /tmp/nk.mp3<br />\ntouch /tmp/nk.mp3<\/p>\n<p>#------- 逐条用getmp3脚本百度语言合成<br />\nwhile [ $j -le $pn ]<br />\ndo<br />\nwords=<code>sed -n "$j,$(($j))p" ${book}<\/code><br />\necho j=$j ${words}<br />\n/home/getmp3 ${words}<br />\n#-------- 逐条合并到nk.mp3<br />\ncat /tmp/getmp3.mp3 >> /tmp/nk.mp3<br />\nwait<br />\nj=$(($j+1))<br />\n#sleep 5<br />\ndone<\/p>\n<p>#-------- 用madplay 或 mplayer 播放<br />\nmadplay /tmp/nk.mp3<br />\n#mplayer /tmp/nk.mp3<\/p>\n","timestamp":1498610808462,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-06-28T00:46:48.462Z","editedISO":"","index":4,"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":701,"uid":255,"tid":78,"content":"<p>创意非常不错!!!<br />\n就是这个没感情的声音听久了人会疯掉<\/p>\n","timestamp":1498631306681,"deleted":0,"replies":{"hasMore":false,"users":[{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","picture":"/uploads/profile/14-profileimg.png","icon:text":"M","icon:bgColor":"#673ab7","administrator":false}],"text":"[[topic:one_reply_to_this_post]]","count":1,"timestampISO":"2017-06-28T11:51:14.245Z"},"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-06-28T06:28:26.681Z","editedISO":"","index":3,"user":{"uid":255,"username":"郭大路","userslug":"郭大路","reputation":0,"postcount":17,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1507512167662,"groupTitle":null,"groupTitleArray":[],"icon:text":"郭","icon:bgColor":"#827717","lastonlineISO":"2017-10-09T01:22:47.662Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":704,"uid":14,"tid":78,"content":"<p><a class=\"plugin-mentions-user plugin-mentions-a\" href=\"https://widora.io/uid/255\">@郭大路<\/a> 这倒是,有个新闻点播源就好了。<\/p>\n","timestamp":1498650674245,"deleted":0,"toPid":"701","upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-06-28T11:51:14.245Z","editedISO":"","index":2,"parent":{"username":"郭大路"},"user":{"uid":14,"username":"midas-zhou","userslug":"midas-zhou","reputation":13,"postcount":138,"picture":"/uploads/profile/14-profileimg.png","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1549845854376,"groupTitle":"","groupTitleArray":[],"icon:text":"M","icon:bgColor":"#673ab7","lastonlineISO":"2019-02-11T00:44:14.376Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":711,"uid":188,"tid":78,"content":"<p>具备商用价值就好了<\/p>\n","timestamp":1498898820304,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"votes":0,"timestampISO":"2017-07-01T08:47:00.304Z","editedISO":"","index":1,"user":{"uid":188,"username":"greeglang","userslug":"greeglang","reputation":0,"postcount":7,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1505465502469,"groupTitle":null,"groupTitleArray":[],"icon:text":"G","icon:bgColor":"#9c27b0","lastonlineISO":"2017-09-15T08:51:42.469Z","banned_until":0,"banned_until_readable":"Not Banned","selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"replies":{"hasMore":false,"users":[],"text":"[[topic:one_reply_to_this_post]]","count":0},"selfPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true}],"category":{"cid":28,"name":"Widora Talk [ZH]","description":"涉及歪朵拉产品的中文讨论板块","descriptionParsed":"<p>涉及歪朵拉产品的中文讨论板块<\/p>\n","icon":"fa-microchip","bgColor":"#4b56d6","color":"#fff","slug":"28/widora-talk-zh","parentCid":0,"topic_count":399,"post_count":1635,"disabled":0,"order":2,"link":"","numRecentReplies":1,"class":"col-md-3 col-xs-6","imageClass":"cover","timesClicked":1,"isSection":0,"totalPostCount":1635,"totalTopicCount":399},"tagWhitelist":[],"thread_tools":[],"isFollowing":false,"isNotFollowing":true,"isIgnoring":false,"bookmark":null,"postSharing":[{"id":"facebook","name":"Facebook","class":"fa-facebook","activated":true},{"id":"twitter","name":"Twitter","class":"fa-twitter","activated":true},{"id":"google","name":"Google+","class":"fa-google-plus","activated":true}],"deleter":null,"merger":null,"related":[],"unreplied":false,"icons":[],"breadcrumbs":[{"text":"[[global:home]]","url":"/"},{"text":"Widora Talk [ZH]","url":"/category/28/widora-talk-zh"},{"text":"Widora-neo应用百度在线语音合成和识别"}],"privileges":{"topics:reply":false,"topics:read":true,"topics:tag":false,"topics:delete":false,"posts:edit":false,"posts:history":false,"posts:delete":false,"posts:view_deleted":false,"read":true,"view_thread_tools":false,"editable":false,"deletable":false,"purge":false,"view_deleted":false,"isAdminOrMod":false,"disabled":0,"tid":"78","uid":-1},"topicStaleDays":60,"reputation:disabled":1,"downvote:disabled":1,"feeds:disableRSS":0,"bookmarkThreshold":5,"postEditDuration":3600,"postDeleteDuration":3600,"scrollToMyPost":true,"allowMultipleBadges":false,"rssFeedUrl":"/topic/78.rss","postIndex":0,"pagination":{"prev":{"page":1,"active":false},"next":{"page":1,"active":false},"rel":[],"pages":[],"currentPage":1,"pageCount":1},"loggedIn":false,"relative_path":"","template":{"name":"topic","topic":true},"url":"/topic/78/widora-neo%E5%BA%94%E7%94%A8%E7%99%BE%E5%BA%A6%E5%9C%A8%E7%BA%BF%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E5%92%8C%E8%AF%86%E5%88%AB","bodyClass":"page-topic page-topic-78 page-topic-widora-neo应用百度在线语音合成和识别 page-topic-category-28 page-topic-category-widora-talk-zh page-status-200","loggedInUser":{"uid":0,"username":"[[global:guest]]","picture":"","icon:text":"?","icon:bgColor":"#aaa"},"widgets":{"footer":[{"html":"<footer id=\"footer\" class=\"container footer\">\r\n\t<div class=\"copyright\">\r\n©widora inc. 2017-2019\r\n<\/div>\r\n<\/footer>"}]}}</script> </div><!-- /.container#content --> </main> <script defer src="/assets/nodebb.min.js?v=qj6shetra0k"></script> <script defer type="text/javascript" src="/assets/vendor/jquery/timeago/locales/jquery.timeago.en.js"></script> <script> window.addEventListener('load', function () { require(['forum/footer']); $(document).ready(function () { function animateTags() { if (ajaxify.data.template.name === 'categories') { var tags = $('.popular-tags .tag-item'); var bar = $('<div class="popular-tags-bar"></div>'); tags.append(bar); var max; setTimeout(function() { tags.each(function() { var bar = $(this).find('.popular-tags-bar'); var val = parseInt(bar.parents('a').find('.tag-topic-count').text(), 10); max = max > val ? max : val; bar.css({ width: val / max * 100 + '%' }); }); }, 100) } } animateTags(); $(window).on('action:ajaxify.end', animateTags); }); }); </script> <div class="hide"> <script> window.addEventListener('load', function () { define(config.relative_path + '/assets/templates/500.js', function () { function compiled(helpers, context, get, iter, helper) { return '<div class="alert alert-danger">\n\t<strong>Internal Error.</strong>\n\t<p>Oops! Looks like something went wrong!</p>\n\t<p>' + helpers.__escape(get(context && context['path'])) + '</p>\n\t' + (get(context && context['error']) ? '<p>' + helpers.__escape(get(context && context['error'])) + '</p>' : '') + '\n\n\t' + (get(context && context['returnLink']) ? '\n\t<p>Press back to return to the previous page</p>\n\t' : '') + '\n</div>\n'; } return compiled; }); }); </script> </div> </body> </html>