{"id":225179,"date":"2014-06-04T20:18:02","date_gmt":"2014-06-04T16:18:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=225179"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=225179","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u0432 Asterisk \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Yandex SpeechKit HTTP API<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3be\/3b6\/1b0\/3be3b61b00a69318b930d0b4124ec0f4.jpg\"\/><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c <a href=\"http:\/\/habrahabr.ru\/post\/133869\/\">\u0421\u0438\u043d\u0442\u0435\u0437 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u043e\u0442 Google \u0434\u043b\u044f Asterisk<\/a>, \u0441 <s>\u043d\u0435<\/s> \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 Yandex SpeechKit HTTP API.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0434\u0438\u0430\u043b\u043f\u043b\u0430\u043d\u0435 \u0432\u0441\u0435 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 (\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f extensions.ael, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 AEL \u0431\u0435\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u0435\u043d \u0447\u0435\u043c extensions.conf):<\/p>\n<pre><code class=\"bash\">s =&gt; {         Answer();         Wait(1);         Record(\/tmp\/${UNIQUEID}.wav,3,20);         AGI(yandex_voice.php,\/tmp\/${UNIQUEID});         NoOp(${TEXT});         Hangup(); }; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0435\u043d: \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u043c \u043d\u0430 \u0437\u0432\u043e\u043d\u043e\u043a, \u0436\u0434\u0435\u043c 1\u0441., \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0447\u044c, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c Asterisk-\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u043d\u044f\u0442\u0435\u043d.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<p>  <i>$key = &#8216;my_secret_key&#8217;<\/i> \u2014 \u044d\u0442\u043e \u0432\u0430\u0448 \u043a\u043b\u044e\u0447 \u043e\u0442 API, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0438\u0441\u044c\u043c\u043e \u043d\u0430 speechkit@yandex-team.ru;<\/p>\n<p>  <i>$topic = &#8216;maps&#8217;<\/i> \u2014 \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b:<\/p>\n<p>  \u2022 freeform \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0438 \u0442.\u0434. \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f: \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430 email \u0438\u043b\u0438 \u0432\u0438\u0434\u0435 SMS.<br \/>  \u2022 general \u2014 web \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435;<br \/>  \u2022 maps \u2014 \u0430\u0434\u0440\u0435\u0441\u0430, GEO-\u0442\u043e\u0447\u043a\u0438 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0440\u043e\u0432, \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u044b\u0435 \u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u0433\u043e\u0441\u0442\u0438\u043d\u0438\u0446\u044b \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0438 \u0442.\u0434.;<br \/>  \u2022 music \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0441\u0435\u043d, \u043c\u0443\u0437\u044b\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f \u0438 \u0442.\u0434.<\/p>\n<p>  <i>$lang = &#8216;ru-RU&#8217;<\/i> \u2014 \u044f\u0437\u044b\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0443\u0441\u0441\u043a\u0438\u0439 &#8216;ru-RU&#8217; \u0438 \u0442\u0443\u0440\u0435\u0446\u043a\u0438\u0439 &#8216;tr-TR&#8217;, \u043f\u0440\u0438\u0447\u0435\u043c \u0442\u0443\u0440\u0435\u0446\u043a\u0438\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u0435\u043c \u00abgeneral\u00bb \u0438 \u00abmaps\u00bb;<\/p>\n<p>  <i>$uuid = &#8216;12345678123456781234567812345678&#8217;<\/i> \u2014 32-x \u0446\u0438\u0444\u0438\u0440\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e API \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 Yandex_SpeechKit_HTTP_API_May[5].pdf \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432\u0430\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c, \u0445\u043e\u0442\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043c\u0430\u043d\u0443\u0430\u043b\u0430 \u043f\u043e API \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435 \u0434\u043e\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c, \u043d\u043e \u044d\u0442\u043e \u0438 \u043a \u043b\u0443\u0447\u0448\u0435\u043c\u0443.<\/p>\n<p>  \u0412 \u043c\u043e\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Asterisk-\u0430 \u0444\u0430\u0439\u043b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435: \/usr\/share\/asterisk\/agi-bin\/<\/p>\n<p>  \u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043a\u043e\u0434 yandex_voice.php: <\/p>\n<pre><code class=\"php\">#!\/usr\/bin\/php -q &lt;? $agivars = array(); while (!feof(STDIN)) {     $agivar = trim(fgets(STDIN));     if ($agivar === '')         break;      $agivar = explode(':', $agivar);     $agivars[$agivar[0]] = trim($agivar[1]); } extract($agivars);  $filename = $_SERVER[&quot;argv&quot;][1]; $key = 'my_secret_key'; $topic = &quot;maps&quot;; $lang = &quot;ru-RU&quot;; $uuid = &quot;12345678123456781234567812345678&quot;;  system('sox '.$filename.'.wav -r 16000 -b 16 -c 1 '.$filename.'-pcm.wav'); $cmd = exec('curl --silent -F &quot;Content-Type=audio\/x-pcm;bit=16;rate=16000&quot; -F &quot;audio=@'.$filename.'-pcm.wav&quot; asr.yandex.net\/asr_xml\\?key='.$key.'\\&uuid='.$uuid .'\\&topic='.$topic.'\\&lang='.$lang, $xml);   $res_xml = implode($xml); if (preg_match('!&lt;variant .*?&gt;(.*)&lt;\/variant&gt;!si', $res_xml, $arr)) $voice_text = $arr[1]; \telse $voice_text=''; \t echo 'SET VARIABLE TEXT &quot;'.$voice_text.'&quot;'.&quot;\\n&quot;; fgets(STDIN); echo 'VERBOSE (&quot;'.$voice_text.'&quot;)'.&quot;\\n&quot;; fgets(STDIN); exit(0); ?&gt; <\/code><\/pre>\n<p>  \u0414\u0430, \u043a\u043e\u0434 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c AGI \u0438\u043b\u0438 ARI \u0441\u043a\u0440\u0438\u043f\u0442\u0435. \u041a\u0430\u043a \u043e\u043d \u0441\u0435\u0439\u0447\u0430\u0441 \u0443 \u043c\u0435\u043d\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0430\u0431\u043e\u043d\u0435\u043d\u0442. \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\/225179\/\"> http:\/\/habrahabr.ru\/post\/225179\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3be\/3b6\/1b0\/3be3b61b00a69318b930d0b4124ec0f4.jpg\"\/><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c <a href=\"http:\/\/habrahabr.ru\/post\/133869\/\">\u0421\u0438\u043d\u0442\u0435\u0437 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u043e\u0442 Google \u0434\u043b\u044f Asterisk<\/a>, \u0441 <s>\u043d\u0435<\/s> \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 Yandex SpeechKit HTTP API.  <\/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-225179","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/225179","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=225179"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/225179\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}