{"id":311298,"date":"2020-10-12T03:00:11","date_gmt":"2020-10-12T03:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=311298"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=311298","title":{"rendered":"\u0413\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0439 \u0431\u043e\u0442 + \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u043c OpenSource. \u0427\u0430\u0441\u0442\u044c 2 \u2014 \u0443\u0447\u0438\u043c \u0431\u043e\u0442\u0430 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/522842\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n6\/2g\/wv\/n62gwv0s5thtycknmpayeuos0_e.jpeg\"><\/div>\n<p>  \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/511722\/\">\u043f\u0435\u0440\u0432\u043e\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0430\u0442 \u0431\u043e\u0442\u0430, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0443\u044e \u0440\u0435\u0447\u044c \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0447\u0430\u0442-\u0431\u043e\u0442 \u0437\u0430\u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0438 \u043d\u0430\u0447\u0430\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<ol>\n<li>\u041e\u0437\u0432\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0432\u0435\u0442\u043d\u044b\u0435 \u0444\u0440\u0430\u0437\u044b <\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430 <\/li>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438 \u0438 \u043d\u0430\u0448\u0435\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0441 \u0447\u0430\u0442-\u0431\u043e\u0442\u043e\u043c <\/li>\n<\/ol>\n<p>  <\/p>\n<h1>\u0428\u0430\u0433 1: \u041e\u0437\u0432\u0443\u0447\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u043d\u044b\u0445 \u0444\u0440\u0430\u0437<\/h1>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448 \u0431\u043e\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0444\u0440\u0430\u0437\u044b, \u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043e\u0437\u0432\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043e\u0442\u0432\u0435\u0442\u043d\u044b\u0435 \u0444\u0440\u0430\u0437\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 yandex speechkit. \u041f\u043e\u043b\u043e\u0436\u0438\u043c \u0438\u0445 \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 freeswitch \/usr\/share\/freeswitch\/sounds\/en\/us\/callie\/ivr \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0435\u0436\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u0438\u043c\u0435\u043d\u0438 \u0434\u043e 50 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<h1>\u0428\u0430\u0433 2: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438<\/h1>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0440\u043e\u0431\u043e\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u0443, \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438. \u0411\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438 Freeswitch. <\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c freeswitch \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0443\u044e \u0440\u0435\u0447\u044c, \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 vosk.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 freeswitch \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 mod_vosk \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/alphacep\/freeswitch\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c vosk. \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e <a href=\"https:\/\/freeswitch.org\/confluence\/display\/FREESWITCH\/Debian+10+Buster\" rel=\"nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a>\u043d\u0430 \u0441\u0430\u0439\u0442\u0435 freeswitch. <b>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442<\/b>, \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b mod_vosk \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c libks \u0438\u0437 <a href=\"https:\/\/github.com\/alphacep\/libks\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>  <b>PS.<\/b> \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Freeswitch \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044d\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <a href=\"https:\/\/www.fusionpbx.com\/download\" rel=\"nofollow\">FusionPBX<\/a><\/p>\n<h1>\u0428\u0430\u0433 3: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430<\/h1>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 <a href=\"https:\/\/alphacephei.com\/ru\/\" rel=\"nofollow\">vosk<\/a>. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435.<\/p>\n<pre><code class=\"bash\">docker run -d -p 2700:2700 alphacep\/kaldi-ru:latest<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c mod_vosk \u0434\u043b\u044f freeswitch, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/etc\/freeswitch\/autoload_configs \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b vosk.conf.xml, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0433\u043e vosk \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"xml\">&lt;configuration name=&quot;vosk.conf&quot; description=&quot;Vosk ASR Configuration&quot;&gt;   &lt;settings&gt;     &lt;param name=&quot;server-url&quot; value=&quot;ws:\/\/localhost:2700&quot;\/&gt;     &lt;param name=&quot;return-json&quot; value=&quot;0&quot;\/&gt;   &lt;\/settings&gt; &lt;\/configuration&gt;<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0430\u043c freeswitch<\/p>\n<pre><code class=\"bash\">systemctl start freeswitch<\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c<\/p>\n<pre><code class=\"bash\">fs_cli -x &quot;load mod_vosk<\/code><\/pre>\n<p>  <\/p>\n<h1>\u0428\u0430\u0433 4: \u0421\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430<\/h1>\n<p>  \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u043a\u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438 \u0441 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e \u0447\u0430\u0442 \u0431\u043e\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c rest api \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 lua \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 rest api \u0438 \u043e\u0437\u0432\u0443\u0447\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<h1>\u0428\u0430\u0433 4.1: REST API \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438<\/h1>\n<p>  \u0421\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 http \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Fastapi \u0434\u043b\u044f python. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Prediction, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<pre><code class=\"python\">class Prediction(BaseModel): \ttext: str<\/code><\/pre>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c<\/p>\n<pre><code class=\"python\">model = Sequential() model.add(LSTM(64,return_sequences=True,input_shape=(description_length, num_encoder_tokens))) model.add(LSTM(32)) model.add(Dropout(0.25)) model.add(Dense(1024, activation='relu')) model.add(Dropout(0.25)) model.add(Dense(158, activation='softmax')) opt=keras.optimizers.adam(lr=0.01,amsgrad=True) model.compile(loss='categorical_crossentropy', \t\t\t\t  optimizer=opt, \t\t\t\t  metrics=['accuracy']) #model.summary()  model.load_weights(&quot;h_10072020.h5&quot;)<\/code><\/pre>\n<p>  \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<pre><code class=\"python\">def get_answer(text): \tt = preprocess_ru_text(text) # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0443 \u0442\u0435\u043a\u0441\u0442\u0430, \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043a\u0430\u043a \u0438 \u043f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \tinput_data = np.zeros( \t\t\t(1,description_length,num_encoder_tokens), \t\t\tdtype='float32') \tj=0 \tfor word in t: \t\twordidxs = np.zeros((num_encoder_tokens),dtype='float32') \t\tif word in input_token_index: \t\t\twordidxs[input_token_index[word]]=1 \t\t\tinput_data[0,j]=wordidxs \t\t\tj+=1 \t\t\tprint(word) \tresults = model.predict(input_data) \tprint (results[0][np.argmax(results)],           list(y_dict)[np.argmax(results)]) \tif results[0][np.argmax(results)]&gt;0.5: \t\treturn random.choice(result_config['intents'][list(y_dict)[np.argmax(results)]]['responses']) \telse: #\u0435\u0441\u043b\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 50%, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0444\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441. \t\treturn random.choice(result_config['failure_phrases'])<\/code><\/pre>\n<p>  \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443:<\/p>\n<pre><code class=\"python\">@app.post('\/prediction\/',response_model=Prediction) async def prediction_route(text: Prediction): \tquestion = text.text \tanswer = get_answer(question) \treturn HTMLResponse(content=clear_text(answer)[:50], status_code=200) # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043e 50, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u043e\u0437\u0432\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<pre><code class=\"bash\">uvicorn main:app --reload --host 0.0.0.0<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0430 <a href=\"http:\/\/localhost\" rel=\"nofollow\">localhost<\/a>:8000\/prediction:<\/p>\n<pre><code class=\"json\">{ \t&quot;text&quot;:&quot;\u043f\u0440\u0438\u0432\u0435\u0442&quot; }<\/code><\/pre>\n<p>  \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"xml\">\u0425\u0430\u0439<\/code><\/pre>\n<p>  <\/p>\n<h1>\u0428\u0430\u0433 4.2: LUA \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 freeswitch<\/h1>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430\u043c\u0438 lua \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0437\u0432\u043e\u043d\u043a\u0430, \u0432\u043e \u0432\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u043e\u0437\u0432\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0444\u0440\u0430\u0437\u043e\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f http \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0437 lua \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"http:\/\/w3.impa.br\/~diego\/software\/luasocket\/\" rel=\"nofollow\">luasocket<\/a>. <\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u0441\u0432\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u0442\u0440\u043e\u0447\u043a\u0443:<\/p>\n<pre><code class=\"lua\">package.path = package.path .. &quot;;&quot; .. [[\/usr\/share\/lua\/5.2\/?.lua]];<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u043d\u0430\u0448\u0435\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438:<\/p>\n<pre><code class=\"lua\">function sendRequest(speech_res)   local path = &quot;http:\/\/localhost:8000\/prediction\/&quot;;   local payload = string.format(&quot;{\\&quot;text\\&quot;:\\&quot;%s\\&quot;}&quot;,speech_res);   log.notice(payload);   local response_body = { };   log.notice(path);   local res, code, response_headers, status = http.request   {     url = path,     method = &quot;POST&quot;,     headers =     {       [&quot;Authorization&quot;] = &quot;&quot;,       [&quot;Content-Type&quot;] = &quot;application\/json&quot;,       [&quot;Content-Length&quot;] = payload:len()     },     source = ltn12.source.string(payload),     sink = ltn12.sink.table(response_body)   }   return trim1(table.concat(response_body)) end<\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043d\u044b\u0445 \u0444\u0440\u0430\u0437:<\/p>\n<pre><code class=\"lua\">session:execute(&quot;play_and_detect_speech&quot;, &quot;ivr\/\u043f\u0440\u0438\u0432\u0435\u0442 \u044f \u043c\u043e\u0433\u0443 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0431\u0435 \u0444\u0438\u043b\u044c\u043c \u0438\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b.wav detect:vosk default&quot;); while session:ready() do     local res = session:getVariable('detect_speech_result'); \tif res ~= nil then \t\tlocal speech_res = session:getVariable(&quot;detect_speech_result&quot;); \t\tlocal response_body = sendRequest(speech_res); \t\tlog.notice(response_body); \t\tsession:execute(&quot;play_and_detect_speech&quot;, &quot;ivr\/&quot;..response_body..&quot;.wav detect:vosk default&quot;); \tend end<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u0435\u0441\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"xml\">&lt;extension name=&quot;7000&quot; continue=&quot;false&quot;&gt; \t&lt;condition field=&quot;destination_number&quot; expression=&quot;7000&quot;&gt; \t\t&lt;action application=&quot;lua&quot; data=&quot;test_vosk.lua&quot;\/&gt; \t&lt;\/condition&gt; &lt;\/extension&gt;<\/code><\/pre>\n<p>  \u0418 \u043f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0438:<\/p>\n<pre><code class=\"bash\">fs_cli -x &quot;reloadxml&quot;<\/code><\/pre>\n<p>  <\/p>\n<h1>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0438 freeswitch \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043d\u0438\u0442\u044c \u043d\u0430 \u043d\u043e\u043c\u0435\u0440 \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c lua \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 \u0440\u043e\u0431\u043e\u0442\u043e\u043c.<\/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=\"https:\/\/habr.com\/ru\/post\/522842\/\"> https:\/\/habr.com\/ru\/post\/522842\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/522842\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n6\/2g\/wv\/n62gwv0s5thtycknmpayeuos0_e.jpeg\"><\/div>\n<p>  \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/511722\/\">\u043f\u0435\u0440\u0432\u043e\u0439<\/a> \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0430\u0442 \u0431\u043e\u0442\u0430, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0443\u044e \u0440\u0435\u0447\u044c \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442.  <\/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-311298","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311298","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=311298"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311298\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}