{"id":298685,"date":"2020-02-14T09:00:28","date_gmt":"2020-02-14T09:00:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298685"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298685","title":{"rendered":"\u041a\u0430\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0447\u044c \u0432 \u044d\u043c\u043e\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Web Speech API \u0438 Node.js"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488132\/\">\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 Diogo Sp\u00ednola <a href=\"https:\/\/www.freecodecamp.org\/news\/speech-to-sentiment-with-chrome-and-nodejs\/\" rel=\"nofollow\">\u00abHow to Build a Speech to Emotion Converter with the Web Speech API and Node.js\u00bb<\/a>.<\/p>\n<p>  \u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043e \u0442\u043e\u043c, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 Node.js \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0438\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0440\u0435\u0447\u0438?<\/p>\n<p>  \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u0438\u0441\u044c\u043c\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u043d\u043e\u043c. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443 \u043c\u043e\u0433\u043b\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u044e, \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0447\u0443\u0432\u0441\u0442\u0432.<\/p>\n<p>  \u042f \u0441\u043f\u0440\u043e\u0441\u0438\u043b \u0441\u0435\u0431\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Node.js.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439, \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0440\u0435\u0447\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041f\u0440\u043e\u0435\u043a\u0442<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/--\/z7\/yz\/--z7yzaebgytoi1omwbzmpy6j5y.png\"><br \/>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 -&gt; \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0437\u0432\u0443\u043a\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442 -&gt; \u043e\u0446\u0435\u043d\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 -&gt; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u0442\u0435 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0446\u0435\u043b\u044c \u0438 \u0442\u043e, \u043a\u0430\u043a \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ul>\n<li>\u0437\u0430\u043f\u0438\u0441\u044c \u0433\u043e\u043b\u043e\u0441\u0430<\/li>\n<li>\u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0435\u043a\u0441\u0442<\/li>\n<li>\u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442<\/li>\n<li>\u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/li>\n<\/ul>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043f\u0443\u0441\u0442\u044f \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0433\u043e\u043b\u043e\u0441\u0430 \u0438 \u0435\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Web_Speech_API\" rel=\"nofollow\">Web Speech API<\/a>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432 Google Chrome. \u0412 \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/SpeechRecognition\" rel=\"nofollow\">\u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438<\/a> \u0435\u0441\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u0442\u043e \u044f \u043d\u0430\u0448\u0435\u043b <a href=\"http:\/\/www2.imm.dtu.dk\/pubdb\/views\/publication_details.php?id=6010\" rel=\"nofollow\">AFINN<\/a>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432 \u0441 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u043c. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435\u0433\u043e 2477 \u0441\u043b\u043e\u0432, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HTML, CSS \u0438 JavaScript.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u00ab\u0441\u043b\u0443\u0448\u0430\u0435\u0442\u00bb \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f WSAPI<\/li>\n<li>\u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 Node.js-\u0441\u0435\u0440\u0432\u0435\u0440<\/li>\n<li>\u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f AFINN, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/li>\n<li>\u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u043c\u043e\u0434\u0437\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u043c\u0435\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b.<\/p>\n<h3>\u0424\u0430\u0439\u043b\u044b \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>  \u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430) \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"xml\">src\/ |-public \/\/ \u043f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430   |-style \/\/ \u043f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f CSS \u0438 \u044d\u043c\u043e\u0434\u0437\u0438     |-css \/\/ \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e       |-emojis.css     |-images \/\/ \u043f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f \u044d\u043c\u043e\u0434\u0437\u0438   |-index.html   |-recognition.js package.json server.js \/\/ Node.js-\u0441\u0435\u0440\u0432\u0435\u0440 <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"xml\">&lt;html&gt; &lt;head&gt;     &lt;title&gt;         \u0420\u0435\u0447\u044c \u0432 \u044d\u043c\u043e\u0446\u0438\u0438     &lt;\/title&gt;     &lt;link rel=&quot;stylesheet&quot; href=&quot;style\/css\/emojis.css&quot;&gt; &lt;\/head&gt; &lt;body&gt;     \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442     &lt;script src=&quot;recognition.js&quot;&gt;&lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c recognition.js \u0432 DOMContentLoaded, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \u0434\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"javascript\">document.addEventListener('DOMContentLoaded', speechToEmotion, false)  function speechToEmotion() {     \/\/ Web Speech API } <\/code><\/pre>\n<p>  emojis.css \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439.<\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c npm run init \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f package.json \u0432 \u043d\u0430\u0448\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u043a\u0435\u0442\u0430: expressjs \u2014 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 nodemon \u2014 \u0434\u043b\u044f \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044f \u0437\u0430 server.js.<\/p>\n<p>  package.json \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"json\">{     &quot;name&quot;: &quot;speech-to-emotion&quot;,     &quot;version&quot;: &quot;1.0.0&quot;,     &quot;description&quot;: &quot;We speak and it feels us :o&quot;,     &quot;main&quot;: &quot;index.js&quot;,     &quot;scripts&quot;: {         &quot;server&quot;: &quot;node server.js&quot;,         &quot;server-debug&quot;: &quot;nodemon --inspect server.js&quot;     },     &quot;author&quot;: &quot;daspinola&quot;,     &quot;license&quot;: &quot;MIT&quot;,     &quot;dependencies&quot;: {         &quot;express&quot;: &quot;^4.17.1&quot;     },     &quot;devDependencies&quot;: {         &quot;nodemon&quot;: &quot;^2.0.2&quot;     } } <\/code><\/pre>\n<p>  server.js \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"javascript\">const express = require('express') const path = require('path')  const port = 3000 const app = express()  app.use(express.static(path.join(__dirname, 'public')))  app.get('\/', function(req, res) {     res.sendFile(path.join(__dirname, 'index.html')) })  app.get('\/emotion', function(req, res) {     \/\/ \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442     res.send() })  app.listen(port, function() {     console.log(`Listening on port ${port}!`) }) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b npm run server-debug \u0438 \u043e\u0442\u0440\u044b\u0442\u044c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 localhost:3000. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u00ab\u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442\u00bb \u0438\u0437 html.<\/p>\n<h3>Web Speech API<\/h3>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 API \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0441 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>  \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0447\u0430\u043b\u043e \u0438 \u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0430\u0443\u0434\u0438\u043e.<\/p>\n<p>  \u041f\u043e\u043a\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f onresult \u0438 onend \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430.<\/p>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e recognition.js:  <\/p>\n<pre><code class=\"javascript\">const recognition = new webkitSpeechRecognition() recognition.lang = 'en-US'  recognition.onresult = function(event) {     const results = event.results     const transcript = results[0][0].transcript      console.log('text -&gt;', transcript) }  recognition.onend = function() {     console.log('disconnected') }  recognition.start() <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u0432\u0443\u043a\u0430. \u0415\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0421\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/cloud.google.com\/speech-to-text\/docs\/languages\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u043a\u0443\u043d\u0434 (\u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e continuous, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 true. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c.  <\/p>\n<pre><code class=\"javascript\">const recognition = new webkitSpeechRecognition() recognition.lang = 'en-US' recognition.continuous = true  recognition.onresult = function(event) {     const results = event.results;     const transcript = results[results.length - 1][0].transcript      console.log('text -&gt;', transcript) }  recognition.onend = function() {     console.log('disconnected') }  recognition.start() <\/code><\/pre>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e continuous \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 transcript, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c. \u041e\u0442\u043a\u0440\u044b\u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u041d\u0435\u043d\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043b\u0435\u043a\u0441\u0438\u043a\u0430 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u0442\u0441\u044f \u0446\u0435\u043d\u0437\u0443\u0440\u0435 \u0438, \u043f\u043e\u0445\u043e\u0436\u0435, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0435\u0435 \u0443\u0431\u0440\u0430\u0442\u044c. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043b\u0435\u043a\u0441\u0438\u043a\u0443, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 AFINN.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f WSAPI \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 Chrome \u0438 Edge. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u043e\u043b\u0438\u0444\u0438\u043b\u044b.<\/p>\n<h3>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440<\/h3>\n<p>  \u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e fetch. \u041c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c transcript \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0430\u0437\u043e\u0432\u0435\u043c text.<\/p>\n<p>  \u0414\u043e\u043f\u0438\u0448\u0435\u043c onresult:  <\/p>\n<pre><code class=\"javascript\">recognition.onresult = function(event){     const results = event.results     const transcript = results[results.length - 1][0].transcript      \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \/emotion (\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445)     fetch(`\/emotion?text=${transcript}`)     .then(response =&gt; response.json())     .then(result =&gt; console.log('result -&gt; ', result)) \/\/ \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c undefined     .catch(e =&gt; console.error('Request error -&gt; ', e)) } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c POST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<h3>\u042d\u043c\u043e\u0446\u0438\u0438<\/h3>\n<p>  \u041d\u0430\u0448\u0438 \u044d\u043c\u043e\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438, \u0442.\u0435. \u0438\u043c\u0435\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u043e\u0437\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u044d\u043c\u043e\u0446\u0438\u0439: \u0440\u0430\u0434\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b (\u0431\u043e\u043b\u044c\u0448\u0435 0) \u0438 \u043e\u0433\u043e\u0440\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b (\u043d\u0438\u0436\u0435 0). \u0420\u0435\u0439\u0442\u0438\u043d\u0433 0 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0442\u0442\u0435\u043d\u043a\u0443. 0 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u00ab\u0447\u0442\u043e?!\u00bb.<\/p>\n<p>  \u0420\u0435\u0439\u0442\u0438\u043d\u0433 \u0441\u043b\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 AFINN \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442 -5 \u0434\u043e 5 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  hope 2<br \/>  hopeful 2<br \/>  hopefully 2<br \/>  hopeless -2<br \/>  hopelessness -2<br \/>  hopes 2<br \/>  hoping 2<br \/>  horrendous -3<br \/>  horrible -3<br \/>  horrific -3<br \/>  \u0441\u043b\u043e\u0432\u043e&lt;\u043f\u0440\u043e\u0431\u0435\u043b&gt;\u0440\u0435\u0439\u0442\u0438\u043d\u0433<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u044f \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0443 \u0432 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d \u0444\u0440\u0430\u0437\u0443 \u00ab\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u043d\u0435 \u0443\u0436\u0430\u0441\u043d\u043e\u00bb (I hope this is not horrendous; horrendous \u2014 \u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0438\u0439, \u0432\u0441\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0436\u0430\u0441). \u0423 \u00ab\u043d\u0430\u0434\u0435\u044e\u0441\u044c\u00bb (hope) \u0431\u0443\u0434\u0435\u0442 2 \u043e\u0447\u043a\u0430, \u0443 \u00ab\u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0438\u0439\u00bb (horrendous) -3, \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0430\u0448\u0430 \u0444\u0440\u0430\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0441 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u043c -1. \u0421\u043b\u043e\u0432\u0430, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 JSON:  <\/p>\n<pre><code class=\"json\">{     &lt;\u0441\u043b\u043e\u0432\u043e&gt;: &lt;\u0440\u0435\u0439\u0442\u0438\u043d\u0433&gt;,     &lt;\u0441\u043b\u043e\u0432\u043e1&gt;: &lt;\u0440\u0435\u0439\u0442\u0438\u043d\u04331&gt;     ... } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430. Andrew Sliwinski \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u044d\u0442\u043e \u0432 <a href=\"https:\/\/github.com\/thisandagain\/sentiment\" rel=\"nofollow\">\u00absentiment\u00bb (\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435)<\/a>. \u0422\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0441 \u043d\u0443\u043b\u044f, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e npm install sentiment \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 server.js \u0438\u043c\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:  <\/p>\n<pre><code class=\"javascript\">const Sentiment = require('sentiment') <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 &#8216;\/emotion&#8217;:  <\/p>\n<pre><code class=\"javascript\">app.get('\/emotion', function(req, res){     const sentiment = new Sentiment()     const text = req.query.text     const score = sentiment.analyze(text)      res.send(score) }) <\/code><\/pre>\n<p>  sentiment.analyze() \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 AFINN \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f score \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"xml\">{     score: 7,     comparative: 2.3333333333333335,     calculation: [ { awesome: 4 }, { good: 3 } ],     tokens: [ 'good', 'awesome', 'film' ],     words: [ 'awesome', 'good' ],     positive: [ 'awesome', 'good' ],     negative: [] } <\/code><\/pre>\n<p>  \u041d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u043b\u044b\u0431\u043a\u0443<\/h3>\n<p>  \u041e\u0431\u043d\u043e\u0432\u0438\u043c index.html, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u043c\u043e\u0434\u0437\u0438:  <\/p>\n<pre><code class=\"xml\">&lt;html&gt;   &lt;head&gt;     &lt;title&gt;       Speech to emotion     &lt;\/title&gt;     &lt;link rel=&quot;stylesheet&quot; href=&quot;style\/css\/emojis.css&quot;&gt;   &lt;\/head&gt;   &lt;body&gt;     &lt;div class=&quot;emoji&quot;&gt;       &lt;img class=&quot;idle&quot;&gt;     &lt;\/div&gt;     &lt;script src=&quot;recognition.js&quot;&gt;&lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u042d\u043c\u043e\u0434\u0437\u0438 \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b <a href=\"https:\/\/www.iconfinder.com\/iconsets\/emoji-66\" rel=\"nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a> (\u043e\u043d\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f). \u0420\u0435\u0441\u043f\u0435\u043a\u0442 \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u0443.<\/p>\n<p>  \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u044d\u043c\u043e\u0434\u0437\u0438 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044d\u043c\u043e\u0434\u0437\u0438:<br \/>  error \u2014 \u043e\u0448\u0438\u0431\u043a\u0430<br \/>  idle \u2014 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d<br \/>  listening \u2014 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d \u0432\u043a\u043b\u044e\u0447\u0435\u043d<br \/>  negative \u2014 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<br \/>  neutral \u2014 0<br \/>  positive \u2014 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<br \/>  seaching \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<p>  emojis.css \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"css\">.emoji img {   width: 100px;   width: 100px; }  .emoji .error {   content:url(&quot;..\/images\/error.png&quot;); }  .emoji .idle {   content:url(&quot;..\/images\/idle.png&quot;); }  .emoji .listening {   content:url(&quot;..\/images\/listening.png&quot;); }  .emoji .negative {   content:url(&quot;..\/images\/negative.png&quot;); }  .emoji .neutral {   content:url(&quot;..\/images\/neutral.png&quot;); }  .emoji .positive {   content:url(&quot;..\/images\/positive.png&quot;); }  .emoji .searching {   content:url(&quot;..\/images\/searching.png&quot;); } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u044d\u043c\u043e\u0434\u0437\u0438 idle. \u042d\u043c\u043e\u0434\u0437\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0442\u0435\u0433\u0430 \u00abimg\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c recognition.js, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043c\u0435\u043d\u044b \u044d\u043c\u043e\u0434\u0437\u0438:  <\/p>\n<pre><code class=\"javascript\">\/** * @param {string} \u0442\u0438\u043f - \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c \u0438\u0437: * error|idle|listening|negative|positive|searching *\/ function setEmoji(type){     const emojiElem = document.querySelector('.emoji img')     emojiElem.classList = type } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e setEmoji \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c:  <\/p>\n<pre><code class=\"javascript\">console.log(transcript)  setEmoji('searching')  fetch(`\/emotion?text=${transcript}`) .then(response =&gt; response.json()) .then(result =&gt; {     if(result.score &gt; 0){         setEmoji('positive')     } else if(result.score &lt; 0){         setEmoji('negative')     } else {         setEmoji('listening')     } }) .catch(e =&gt; {     console.error('Request error -&gt;', e)     recognition.abort() }) <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f onerror \u0438 onaudiostart \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 onend, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u044d\u043c\u043e\u0434\u0437\u0438:  <\/p>\n<pre><code class=\"javascript\">recognition.onerror = function(event) {     console.error('Recognition error -&gt;', event.error)     setEmoji('error') }  recognition.onaudiostart = () =&gt; setEmoji('listening')  recognition.onend = () =&gt; setEmoji('idle') <\/code><\/pre>\n<p>  \u00ab\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439\u00bb recognition.js \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"javascript\">document.addEventListener('DOMContentLoaded', speechToEmotion, false);  function speechToEmotion() {   const recognition = new webkitSpeechRecognition()   recognition.lang = 'en-US'   recognition.continuous = true    recognition.onresult = function(event) {     const results = event.results;     const transcript = results[results.length-1][0].transcript      console.log(transcript)      setEmoji('searching')      fetch(`\/emotion?text=${transcript}`)       .then((response) =&gt; response.json())       .then((result) =&gt; {         if (result.score &gt; 0) {           setEmoji('positive')         } else if (result.score &lt; 0) {           setEmoji('negative')         } else {           setEmoji('listening')         }       })       .catch((e) =&gt; {         console.error('Request error -&gt; ', e)         recognition.abort()       })   }    recognition.onerror = function(event) {     console.error('Recognition error -&gt; ', event.error)     setEmoji('error')   }    recognition.onaudiostart = () =&gt; setEmoji('listening')    recognition.onend = () =&gt; setEmoji('idle')    recognition.start();    \/**    * @param {string} type - could be any of the following:    *   error|idle|listening|negative|positive|searching    *\/   function setEmoji(type) {     const emojiElem = document.querySelector('.emoji img')     emojiElem.classList = type   } } <\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e console.log \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 html.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<ul>\n<li>\u043e\u043d \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0441\u0430\u0440\u043a\u0430\u0437\u043c<\/li>\n<li>\u043e\u043d \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0433\u043d\u0435\u0432 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0438\u0437-\u0437\u0430 \u0446\u0435\u043d\u0437\u0443\u0440\u044b API \u043d\u0430 \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043b\u0435\u043a\u0441\u0438\u043a\u0443)<\/li>\n<li>\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442<\/li>\n<\/ul>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/www.youtube.com\/watch?v=pd-X2RnVYxc\" rel=\"nofollow\">\u0432\u0438\u0434\u0435\u043e<\/a>.<\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/github.com\/daspinola\/speech-to-emotion\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0414\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447.<\/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=\"https:\/\/habr.com\/ru\/post\/488132\/\"> https:\/\/habr.com\/ru\/post\/488132\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488132\/\">\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 Diogo Sp\u00ednola <a href=\"https:\/\/www.freecodecamp.org\/news\/speech-to-sentiment-with-chrome-and-nodejs\/\" rel=\"nofollow\">\u00abHow to Build a Speech to Emotion Converter with the Web Speech API and Node.js\u00bb<\/a>.<\/p>\n<p>  \u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043e \u0442\u043e\u043c, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 Node.js \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0438\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0440\u0435\u0447\u0438?<\/p>\n<p>  \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u0438\u0441\u044c\u043c\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u043d\u043e\u043c. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443 \u043c\u043e\u0433\u043b\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u044e, \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0447\u0443\u0432\u0441\u0442\u0432.<\/p>\n<p>  \u042f \u0441\u043f\u0440\u043e\u0441\u0438\u043b \u0441\u0435\u0431\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Node.js.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439, \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0440\u0435\u0447\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f.  <\/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-298685","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298685","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=298685"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298685\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}