{"id":157333,"date":"2012-11-04T13:37:03","date_gmt":"2012-11-04T09:37:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=157333"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=157333","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u043d\u0430 Bash<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0423\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 %username%.<\/p>\n<h4>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0438 \u0433\u043e\u043b\u043e\u0441\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a Bash. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 OC \u044f \u0432\u044b\u0431\u0440\u0430\u043b Ubuntu 12.04<\/p>\n<h4>\u0411\u043b\u0438\u0436\u0435 \u043a \u0442\u0435\u043c\u0435<\/h4>\n<p>  \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c Google, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 Google Chrome \u0434\u043b\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c?<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b<\/h5>\n<p>  <\/p>\n<ol>\n<li>\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0444\u0430\u0439\u043b speech.wav \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0441 \u0440\u0435\u0439\u0442\u043e\u043c 16 \u043c\u0413\u0446<\/li>\n<li>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c speech.wav \u0432 speech.flac (\u043b\u0438\u0448\u044c \u0442\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c Google)<\/li>\n<li>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c Google speech.flac, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c Google Chrome<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432\u0438\u0434\u0430:<br \/>  <code>{&quot;status&quot;:0,&quot;id&quot;:&quot;37h03bf4efe17fa76594732d6dokf3-1&quot;,&quot;hypotheses&quot;:[{&quot;utterance&quot;:&quot;\u0440\u0430\u0437 \u0434\u0432\u0430 \u0442\u0440\u0438&quot;,&quot;confidence&quot;:0.75936891}]}<\/code><br \/>  \u0440\u0430\u0437 \u0434\u0432\u0430 \u0442\u0440\u0438 \u2014 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<br \/>  0.75936891 \u2014 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 0.5, \u0442\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u044b\u043c)<\/li>\n<li>\u0412\u044b\u0447\u043b\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f utterance \u0438 confidence \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0445 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d<\/li>\n<\/ol>\n<h5>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h5>\n<p>  <\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0430\u0439\u043b speech.sh \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f (\u043a\u043e\u0434 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438):<br \/> \n<pre><code class=\"bash\">#!\/bin\/bash echo &quot;\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c...&quot; arecord -d 3 -q -f cd -r 16000 speech.wav # \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0444\u0430\u0439\u043b speech.wav \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0441 \u0440\u0435\u0439\u0442\u043e\u043c 16 \u043c\u0413\u0446 echo &quot;\u0417\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430&quot; sox speech.wav speech.flac gain -n -5 silence 1 5 2% # \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c speech.wav \u0432 speech.flac rm speech.wav # \u0423\u0434\u0430\u043b\u044f\u0435\u043c speech.wav, \u0442.\u043a. \u043e\u043d \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f echo &quot;\u0410\u043d\u0430\u043b\u0438\u0437 \u0433\u043e\u043b\u043e\u0441\u0430...&quot; wget -q -U &quot;Mozilla\/5.0&quot; --post-file speech.flac --header=&quot;Content-Type: audio\/x-flac; rate=16000&quot; -O - &quot;http:\/\/www.google.com\/speech-api\/v1\/recognize?lang=ru-RU&client=chromium&quot; &gt; all.ret # \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c Google speech.flac, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c Google Chrome \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0444\u0430\u0439\u043b all.ret rm speech.flac # \u0423\u0434\u0430\u043b\u044f\u0435\u043c speech.flac, \u0442.\u043a. \u043e\u043d \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f cat all.ret | sed 's\/.*utterance&quot;:&quot;\/\/' | sed 's\/&quot;,&quot;confidence.*\/\/' &gt; text.txt # \u0412\u044b\u0447\u043b\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 utterance \u0432 \u0444\u0430\u0439\u043b text.txt cat all.ret | sed 's\/.*confidence&quot;:\/\/' | sed 's\/}]}.*\/\/' &gt; confidence.txt # \u0412\u044b\u0447\u043b\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 confidence \u0432 \u0444\u0430\u0439\u043b confidence.txt rm all.ret # \u0423\u0434\u0430\u043b\u044f\u0435\u043c all.ret, \u0442.\u043a. \u043e\u043d \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f TEXT=&quot;$(cat text.txt)&quot; # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 TEXT \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 text.txt  CONFIDENCE=&quot;$(cat confidence.txt)&quot; # \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 CONFIDENCE \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 confidence.txt rm text.txt # \u0423\u0434\u0430\u043b\u044f\u0435\u043c text.txt, \u0442.\u043a. \u043e\u043d \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f rm confidence.txt # \u0423\u0434\u0430\u043b\u044f\u0435\u043c confidence.txt, \u0442.\u043a. \u043e\u043d \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f echo $TEXT # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 TEXT echo $CONFIDENCE # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 CONFIDENCE <\/code><\/pre>\n<\/li>\n<li>\u0417\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<br \/>  <code>sudo apt-get install lame<\/code><br \/>  <code>sudo apt-get install sox<\/code><\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0444\u0430\u0439\u043b\u0443 speech.sh \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a:<br \/>  <code>sudo chmod 755 speech.sh<\/code><\/li>\n<\/ol>\n<p>  \u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442\u0438\u043a \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<br \/>  <code>.\/speech.sh<\/code><\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443 \u043c\u0435\u043d\u044f:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c43\/569\/215\/c43569215dcb820513d8c1150ae6aea5.jpg\"\/><\/p>\n<h4>\u0418\u0442\u043e\u0433\u043e<\/h4>\n<p>  \u0418 \u0442\u0430\u043a, \u043f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u0438: \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0443\u0436 \u0438 \u00ab\u043d\u0435\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u00bb. \u0423\u043c\u0435\u043b\u044b\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441 \u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u0441\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u044f \u0441\u043e\u0437\u0434\u0430\u044e \u00ab\u0423\u043c\u043d\u044b\u0439 \u0434\u043e\u043c\u00bb \u0441 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u0414\u043e \u0441\u043a\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447, %username%. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/157333\/\"> http:\/\/habrahabr.ru\/post\/157333\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0423\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 %username%.<\/p>\n<h4>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0438 \u0433\u043e\u043b\u043e\u0441\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a Bash. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 OC \u044f \u0432\u044b\u0431\u0440\u0430\u043b Ubuntu 12.04<\/p>\n<h4>\u0411\u043b\u0438\u0436\u0435 \u043a \u0442\u0435\u043c\u0435<\/h4>\n<p>  \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c Google, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 Google Chrome \u0434\u043b\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c?  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-157333","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157333"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157333\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}