{"id":333931,"date":"2022-06-01T21:00:05","date_gmt":"2022-06-01T21:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333931"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333931","title":{"rendered":"<span>\u041a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c AssemblyAI \u0438 Streamlit<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c3b\/ee6\/1b7\/c3bee61b7207aa25002001acee364dca.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c3b\/ee6\/1b7\/c3bee61b7207aa25002001acee364dca.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0443\u0447\u0438\u0442\u044c \u0418\u0418 \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u0448\u0451\u043f\u043e\u0442\u043e\u043c \u2014 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u0430\u0436\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f. \u041d\u043e \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u0442\u0430\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u043f\u0446\u0438\u044f \u0440\u0435\u0447\u0438, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<blockquote>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u043a \u0441\u0442\u0430\u0440\u0442\u0443 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_010622&amp;utm_term=main\"><u>\u043f\u043e Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 Python<\/u><\/a>.<\/p>\n<\/blockquote>\n<hr\/>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0432 \u0440\u0435\u0447\u044c. \u042d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u0447\u0442\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0443 \u043b\u0435\u043a\u0446\u0438\u0439, \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439 \u0438 \u0432\u0441\u0442\u0440\u0435\u0447. \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432: <\/p>\n<ul>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u0438 \u0438 \u0431\u0435\u0441\u0435\u0434\u044b. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0439\u0441\u044f \u0441\u0440\u0435\u0434\u0435, \u0438 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0434\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u044b\u043a\u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435 \u0432\u044b \u0441\u0430\u043c\u0438 \u0438 \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0434\u0440\u0443\u0433\u0438\u0435. <\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0434\u0438 \u0441 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0445\u0430 \u0438\u043b\u0438 \u0442\u0435, \u043a\u0442\u043e \u0443\u0447\u0438\u0442 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0430\u0443\u0434\u0438\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u0441\u043b\u043e\u0432. \u041a \u0442\u0435\u043a\u0441\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API AssemblyAI (\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c) \u0438 Streamlit (\u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c). <\/p>\n<p>\u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e\u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/62978f7ede22274fb4bad99a\" data-style=\"\" id=\"62978f7ede22274fb4bad99a\" width=\"\"><\/div>\n<h2>\u041e\u0431\u0437\u043e\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f Python:<\/p>\n<ul>\n<li>\n<p>streamlit \u2014 \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432\u0432\u043e\u0434\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>websocket \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 API AssemblyAI;<\/p>\n<\/li>\n<li>\n<p>asyncio \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u0432\u043e\u0434 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>base64 \u2014 \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0438 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0430\u0443\u0434\u0438\u043e\u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0432 API \u200b\u200bAssemblyAI;<\/p>\n<\/li>\n<li>\n<p>json \u2014 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u044b\u0432\u043e\u0434, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 API AssemblyAI (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442);<\/p>\n<\/li>\n<li>\n<p>pyaudio \u2014 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u0432\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 PortAudio;<\/p>\n<\/li>\n<li>\n<p>os \u0438 pathlib \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0430\u043f\u043a\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0441\u0440\u0435\u0434\u044b<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0440\u0435\u0434\u0443 conda \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c transcription:<\/p>\n<pre><code class=\"bash\">conda create -n transcription python=3.9<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b\u0441\u0432\u0435\u0442\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 Y, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ab7\/b90\/32f\/ab7b9032f390594d032bae5948d0af9c.png\" width=\"700\" height=\"437\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab7\/b90\/32f\/ab7b9032f390594d032bae5948d0af9c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u044b conda \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">conda activate transcription<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0430 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0437 \u0441\u0440\u0435\u0434\u044b \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0439\u0442\u0438:<\/p>\n<pre><code class=\"bash\">conda deactivate<\/code><\/pre>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 GitHub-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0441 GitHub \u0432\u0435\u0441\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/dataprofessor\/realtime-transcription<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 realtime-transcription:<\/p>\n<pre><code>cd realtime-transcription<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">pip install -r requirements.txt<\/code><\/pre>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u043e\u0442 API AssemblyAI<\/h2>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API \u0432 AssemblyAI \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 <a href=\"https:\/\/www.assemblyai.com\/?utm_source=youtube&amp;utm_medium=social&amp;utm_campaign=dataprofessor\">\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c<\/a> \u043d\u0430 AssemblyAI, \u044d\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e. \u0417\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. \u041d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 API-\u043a\u043b\u044e\u0447:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f03\/51f\/bda\/f0351fbdad63fdb36da4fe83dd653772.gif\" alt=\"\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API-\u043a\u043b\u044e\u0447 \u0432 AssemblyAI\" title=\"\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API-\u043a\u043b\u044e\u0447 \u0432 AssemblyAI\" width=\"1280\" height=\"868\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f03\/51f\/bda\/f0351fbdad63fdb36da4fe83dd653772.gif\"\/><figcaption>\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API-\u043a\u043b\u044e\u0447 \u0432 AssemblyAI<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 API-\u043a\u043b\u044e\u0447 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b secrets.toml \u0438\u0437 \u043f\u0430\u043f\u043a\u0438.streamlit. \u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: <code>.streamlit\/secrets.toml<\/code>. \u0415\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"python\">api_key = 'xxxxx'<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e xxxxx \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043b\u044e\u0447 \u043e\u0442 API. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 st.secrets[\u2018api_key\u2019].<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 (\u0442\u043e, \u0447\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 tree \u0432 Bash):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/095\/f75\/cf3\/095f75cf32b03718eb30219894033b92.png\" width=\"700\" height=\"452\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/095\/f75\/cf3\/095f75cf32b03718eb30219894033b92.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043f\u043a\u0438 realtime-transcription<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">streamlit run streamlit_app.py<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b3\/0b8\/536\/4b30b8536e3b2a0412ce1e53a478904f.png\" alt=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" title=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" width=\"700\" height=\"473\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b3\/0b8\/536\/4b30b8536e3b2a0412ce1e53a478904f.png\"\/><figcaption>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u00a0\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a34\/e08\/c1c\/a34e08c1cd0f602453b60ba214942575.gif\" alt=\"\u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" title=\"\u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" width=\"1280\" height=\"896\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a34\/e08\/c1c\/a34e08c1cd0f602453b60ba214942575.gif\"\/><figcaption>\u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u00a0<\/p>\n<h2>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 1\u20138<\/strong> \u2014 \u0438\u043c\u043f\u043e\u0440\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 10-13 <\/strong>\u2014 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 15-22<\/strong> \u2014 \u0432\u0432\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0430\u0443\u0434\u0438\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u043c text_input.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 24-31<\/strong> \u2014 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0430\u0443\u0434\u0438\u043e\u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 pyaudio \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e \u0438\u0437 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 33-46<\/strong> \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, start_listening, stop_listening \u0438 download_transcription), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 (\u0441\u043c. \u043d\u0438\u0436\u0435).<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 49<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0440\u043e\u043a\u0443 st.title.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 51\u201362<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 (\u0440\u0430\u0437\u0434\u0435\u043b About) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 st.expander.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 64\u201367<\/strong> \u2014 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 2 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 st.columns \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a \u00ab\u041f\u0443\u0441\u043a\u00bb (Start) \u0438 \u00ab\u0421\u0442\u043e\u043f\u00bb (Stop). \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 start_listening \u0438 stop_listening \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 on_click \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 69\u2013139<\/strong> \u2014 \u0437\u0434\u0435\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0447\u0435\u0432\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430: \u0430\u0443\u0434\u0438\u043e\u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 API AssemblyAI, \u0433\u0434\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u0437 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/misraturp\/Real-time-transcription-from-microphone\">\u041c\u0438\u0441\u0440\u043e\u0439 \u0422\u0443\u0440\u043f<\/a> \u0438 <a href=\"https:\/\/towardsdatascience.com\/real-time-speech-recognition-python-assemblyai-13d35eeed226\">\u0414\u0436\u043e\u0440\u0434\u0436\u0438\u043e\u0441\u043e\u043c \u041c\u0438\u0440\u0438\u0430\u043d\u0442\u0443\u0441\u043e\u043c<\/a>.\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 141\u2013144<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0412\u0435\u0441\u044c \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import streamlit as st import websockets import asyncio import base64 import json import pyaudio import os from pathlib import Path  # \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 if 'text' not in st.session_state: st.session_state['text'] = 'Listening...' st.session_state['run'] = False  # \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e st.sidebar.header('Audio Parameters')  FRAMES_PER_BUFFER = int(st.sidebar.text_input('Frames per buffer', 3200)) FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = int(st.sidebar.text_input('Rate', 16000)) p = pyaudio.PyAudio()  # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0430\u0443\u0434\u0438\u043e\u043f\u043e\u0442\u043e\u043a \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 stream = p.open(    format=FORMAT,    channels=CHANNELS,    rate=RATE,    input=True,    frames_per_buffer=FRAMES_PER_BUFFER )  # \u0417\u0430\u043f\u0443\u0441\u043a \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f def start_listening(): st.session_state['run'] = True  def download_transcription(): read_txt = open('transcription.txt', 'r') st.download_button( label=\"Download transcription\", data=read_txt, file_name='transcription_output.txt', mime='text\/plain')  def stop_listening(): st.session_state['run'] = False  # \u0412\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434) st.title('?\ufe0f Real-Time Transcription App')  with st.expander('About this App'): st.markdown(''' This Streamlit app uses the AssemblyAI API to perform real-time transcription.  Libraries used: - `streamlit` - web framework - `pyaudio` - a Python library providing bindings to [PortAudio](http:\/\/www.portaudio.com\/) (cross-platform audio processing library) - `websockets` - allows interaction with the API - `asyncio` - allows concurrent input\/output processing - `base64` - encode\/decode audio data - `json` - allows reading of AssemblyAI audio output in JSON format ''')  col1, col2 = st.columns(2)  col1.button('Start', on_click=start_listening) col2.button('Stop', on_click=stop_listening)  # \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0443\u0434\u0438\u043e (\u0432\u0432\u043e\u0434) async def send_receive(): URL = f\"wss:\/\/api.assemblyai.com\/v2\/realtime\/ws?sample_rate={RATE}\"  print(f'Connecting websocket to url ${URL}')  async with websockets.connect( URL, extra_headers=((\"Authorization\", st.secrets['api_key']),), ping_interval=5, ping_timeout=20 ) as _ws:  r = await asyncio.sleep(0.1) print(\"Receiving messages ...\")  session_begins = await _ws.recv() print(session_begins) print(\"Sending messages ...\")   async def send(): while st.session_state['run']: try: data = stream.read(FRAMES_PER_BUFFER) data = base64.b64encode(data).decode(\"utf-8\") json_data = json.dumps({\"audio_data\":str(data)}) r = await _ws.send(json_data)  except websockets.exceptions.ConnectionClosedError as e: print(e) assert e.code == 4008 break  except Exception as e: print(e) assert False, \"Not a websocket 4008 error\"  r = await asyncio.sleep(0.01)      # \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u043f\u0446\u0438\u044e (\u0432\u044b\u0432\u043e\u0434) async def receive(): while st.session_state['run']: try: result_str = await _ws.recv() result = json.loads(result_str)['text']  if json.loads(result_str)['message_type']=='FinalTranscript': print(result) st.session_state['text'] = result st.write(st.session_state['text'])  transcription_txt = open('transcription.txt', 'a') transcription_txt.write(st.session_state['text']) transcription_txt.write(' ') transcription_txt.close()   except websockets.exceptions.ConnectionClosedError as e: print(e) assert e.code == 4008 break  except Exception as e: print(e) assert False, \"Not a websocket 4008 error\"  send_result, receive_result = await asyncio.gather(send(), receive())   asyncio.run(send_receive())  if Path('transcription.txt').is_file(): st.markdown('### Download') download_transcription() os.remove('transcription.txt')  # \u0421\u0441\u044b\u043b\u043a\u0438 (\u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u2014 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043d\u0438\u0436\u0435) # 1. https:\/\/github.com\/misraturp\/Real-time-transcription-from-microphone # 2. https:\/\/medium.com\/towards-data-science\/real-time-speech-recognition-python-assemblyai-13d35eeed226<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u0435\u043c, \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u043d\u0430 Python \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API AssemblyAI. \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0443 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (\u0434\u0438\u043a\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0430\u0442\u044c\u0438\/\u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u0438\u0441\u044c\u043c\u0430, \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043d\u0430\u0432\u044b\u043a\u043e\u0432 \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439 \u0441 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0445\u0430 \u0438 \u0442. \u0434.).<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u0436\u0435 \u0434\u043b\u044f \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 API. \u0410 \u043c\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_010622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_010622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e <a href=\"https:\/\/skillfactory.ru\/concalogue?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=sf_allcourses_010622&amp;utm_term=conc\">\u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e<\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/133\/e60\/488\/133e60488999fe51f9a958bd2a28ef91.png\" width=\"1000\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/133\/e60\/488\/133e60488999fe51f9a958bd2a28ef91.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/skillfactory\/blog\/669126\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/669126\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c AssemblyAI \u0438 Streamlit<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0443\u0447\u0438\u0442\u044c \u0418\u0418 \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u0448\u0451\u043f\u043e\u0442\u043e\u043c \u2014 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u0430\u0436\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f. \u041d\u043e \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u0442\u0430\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u043f\u0446\u0438\u044f \u0440\u0435\u0447\u0438, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<blockquote>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u043a \u0441\u0442\u0430\u0440\u0442\u0443 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_010622&amp;utm_term=main\"><u>\u043f\u043e Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 Python<\/u><\/a>.<\/p>\n<\/blockquote>\n<hr\/>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0432 \u0440\u0435\u0447\u044c. \u042d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u0447\u0442\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0443 \u043b\u0435\u043a\u0446\u0438\u0439, \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439 \u0438 \u0432\u0441\u0442\u0440\u0435\u0447. \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432: <\/p>\n<ul>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u0438 \u0438 \u0431\u0435\u0441\u0435\u0434\u044b. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0439\u0441\u044f \u0441\u0440\u0435\u0434\u0435, \u0438 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0434\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u044b\u043a\u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435 \u0432\u044b \u0441\u0430\u043c\u0438 \u0438 \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0434\u0440\u0443\u0433\u0438\u0435. <\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0434\u0438 \u0441 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0445\u0430 \u0438\u043b\u0438 \u0442\u0435, \u043a\u0442\u043e \u0443\u0447\u0438\u0442 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0430\u0443\u0434\u0438\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u0441\u043b\u043e\u0432. \u041a \u0442\u0435\u043a\u0441\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API AssemblyAI (\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c) \u0438 Streamlit (\u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c). <\/p>\n<p>\u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e\u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/62978f7ede22274fb4bad99a\" data-style=\"\" id=\"62978f7ede22274fb4bad99a\" width=\"\"><\/div>\n<h2>\u041e\u0431\u0437\u043e\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f Python:<\/p>\n<ul>\n<li>\n<p>streamlit \u2014 \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432\u0432\u043e\u0434\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>websocket \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 API AssemblyAI;<\/p>\n<\/li>\n<li>\n<p>asyncio \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u0432\u043e\u0434 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>base64 \u2014 \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0438 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0430\u0443\u0434\u0438\u043e\u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0432 API \u200b\u200bAssemblyAI;<\/p>\n<\/li>\n<li>\n<p>json \u2014 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u044b\u0432\u043e\u0434, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 API AssemblyAI (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442);<\/p>\n<\/li>\n<li>\n<p>pyaudio \u2014 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0447\u0435\u0432\u043e\u0439 \u0432\u0432\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 PortAudio;<\/p>\n<\/li>\n<li>\n<p>os \u0438 pathlib \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0430\u043f\u043a\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0441\u0440\u0435\u0434\u044b<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0440\u0435\u0434\u0443 conda \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c transcription:<\/p>\n<pre><code class=\"bash\">conda create -n transcription python=3.9<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b\u0441\u0432\u0435\u0442\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 Y, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u044b conda \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">conda activate transcription<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0430 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0437 \u0441\u0440\u0435\u0434\u044b \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0439\u0442\u0438:<\/p>\n<pre><code class=\"bash\">conda deactivate<\/code><\/pre>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 GitHub-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0441 GitHub \u0432\u0435\u0441\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0447\u0438:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/dataprofessor\/realtime-transcription<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 realtime-transcription:<\/p>\n<pre><code>cd realtime-transcription<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">pip install -r requirements.txt<\/code><\/pre>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u043e\u0442 API AssemblyAI<\/h2>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API \u0432 AssemblyAI \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 <a href=\"https:\/\/www.assemblyai.com\/?utm_source=youtube&amp;utm_medium=social&amp;utm_campaign=dataprofessor\">\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c<\/a> \u043d\u0430 AssemblyAI, \u044d\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e. \u0417\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. \u041d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 API-\u043a\u043b\u044e\u0447:<\/p>\n<figure class=\"full-width\"><figcaption>\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API-\u043a\u043b\u044e\u0447 \u0432 AssemblyAI<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 API-\u043a\u043b\u044e\u0447 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b secrets.toml \u0438\u0437 \u043f\u0430\u043f\u043a\u0438.streamlit. \u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: <code>.streamlit\/secrets.toml<\/code>. \u0415\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"python\">api_key = 'xxxxx'<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e xxxxx \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043b\u044e\u0447 \u043e\u0442 API. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 st.secrets[\u2018api_key\u2019].<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 (\u0442\u043e, \u0447\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 tree \u0432 Bash):<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043f\u043a\u0438 realtime-transcription<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">streamlit run streamlit_app.py<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430:<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u00a0\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u00a0<\/p>\n<h2>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 1\u20138<\/strong> \u2014 \u0438\u043c\u043f\u043e\u0440\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 10-13 <\/strong>\u2014 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 15-22<\/strong> \u2014 \u0432\u0432\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0430\u0443\u0434\u0438\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u043c text_input.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 24-31<\/strong> \u2014 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0430\u0443\u0434\u0438\u043e\u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 pyaudio \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e \u0438\u0437 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 33-46<\/strong> \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, start_listening, stop_listening \u0438 download_transcription), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 (\u0441\u043c. \u043d\u0438\u0436\u0435).<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0430 49<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0440\u043e\u043a\u0443 st.title.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 51\u201362<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 (\u0440\u0430\u0437\u0434\u0435\u043b About) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 st.expander.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 64\u201367<\/strong> \u2014 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 2 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 st.columns \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a \u00ab\u041f\u0443\u0441\u043a\u00bb (Start) \u0438 \u00ab\u0421\u0442\u043e\u043f\u00bb (Stop). \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 start_listening \u0438 stop_listening \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 on_click \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 69\u2013139<\/strong> \u2014 \u0437\u0434\u0435\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0447\u0435\u0432\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430: \u0430\u0443\u0434\u0438\u043e\u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 API AssemblyAI, \u0433\u0434\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u0437 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/misraturp\/Real-time-transcription-from-microphone\">\u041c\u0438\u0441\u0440\u043e\u0439 \u0422\u0443\u0440\u043f<\/a> \u0438 <a href=\"https:\/\/towardsdatascience.com\/real-time-speech-recognition-python-assemblyai-13d35eeed226\">\u0414\u0436\u043e\u0440\u0434\u0436\u0438\u043e\u0441\u043e\u043c \u041c\u0438\u0440\u0438\u0430\u043d\u0442\u0443\u0441\u043e\u043c<\/a>.\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0440\u043e\u043a\u0438 141\u2013144<\/strong> \u2014 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0412\u0435\u0441\u044c \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import streamlit as st import websockets import asyncio import base64 import json import pyaudio import os from pathlib import Path  # \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 if 'text' not in st.session_state: st.session_state['text'] = 'Listening...' st.session_state['run'] = False  # \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e st.sidebar.header('Audio Parameters')  FRAMES_PER_BUFFER = int(st.sidebar.text_input('Frames per buffer', 3200)) FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = int(st.sidebar.text_input('Rate', 16000)) p = pyaudio.PyAudio()  # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0430\u0443\u0434\u0438\u043e\u043f\u043e\u0442\u043e\u043a \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 stream = p.open(    format=FORMAT,    channels=CHANNELS,    rate=RATE,    input=True,    frames_per_buffer=FRAMES_PER_BUFFER )  # \u0417\u0430\u043f\u0443\u0441\u043a \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f def start_listening(): st.session_state['run'] = True  def download_transcription(): read_txt = open('transcription.txt', 'r') st.download_button( label=\"Download transcription\", data=read_txt, file_name='transcription_output.txt', mime='text\/plain')  def stop_listening(): st.session_state['run'] = False  # \u0412\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434) st.title('?\ufe0f Real-Time Transcription App')  with st.expander('About this App'): st.markdown(''' This Streamlit app uses the AssemblyAI API to perform real-time transcription.  Libraries used: - `streamlit` - web framework - `pyaudio` - a Python library providing bindings to [PortAudio](http:\/\/www.portaudio.com\/) (cross-platform audio processing library) - `websockets` - allows interaction with the API - `asyncio` - allows concurrent input\/output processing - `base64` - encode\/decode audio data - `json` - allows reading of AssemblyAI audio output in JSON format ''')  col1, col2 = st.columns(2)  col1.button('Start', on_click=start_listening) col2.button('Stop', on_click=stop_listening)  # \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0443\u0434\u0438\u043e (\u0432\u0432\u043e\u0434) async def send_receive(): URL = f\"wss:\/\/api.assemblyai.com\/v2\/realtime\/ws?sample_rate={RATE}\"  print(f'Connecting websocket to url ${URL}')  async with websockets.connect( URL, extra_headers=((\"Authorization\", st.secrets['api_key']),), ping_interval=5, ping_timeout=20 ) as _ws:  r = await asyncio.sleep(0.1) print(\"Receiving messages ...\")  session_begins = await _ws.recv() print(session_begins) print(\"Sending messages ...\")   async def send(): while st.session_state['run']: try: data = stream.read(FRAMES_PER_BUFFER) data = base64.b64encode(data).decode(\"utf-8\") json_data = json.dumps({\"audio_data\":str(data)}) r = await _ws.send(json_data)  except websockets.exceptions.ConnectionClosedError as e: print(e) assert e.code == 4008 break  except Exception as e: print(e) assert False, \"Not a websocket 4008 error\"  r = await asyncio.sleep(0.01)      # \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u043f\u0446\u0438\u044e (\u0432\u044b\u0432\u043e\u0434) async def receive(): while st.session_state['run']: try: result_str = await _ws.recv() result = json.loads(result_str)['text']  if json.loads(result_str)['message_type']=='FinalTranscript': print(result) st.session_state['text'] = result st.write(st.session_state['text'])  transcription_txt = open('transcription.txt', 'a') transcription_txt.write(st.session_state['text']) transcription_txt.write(' ') transcription_txt.close()   except websockets.exceptions.ConnectionClosedError as e: print(e) assert e.code == 4008 break  except Exception as e: print(e) assert False, \"Not a websocket 4008 error\"  send_result, receive_result = await asyncio.gather(send(), receive())   asyncio.run(send_receive())  if Path('transcription.txt').is_file(): st.markdown('### Download') download_transcription() os.remove('transcription.txt')  # \u0421\u0441\u044b\u043b\u043a\u0438 (\u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u2014 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043d\u0438\u0436\u0435) # 1. https:\/\/github.com\/misraturp\/Real-time-transcription-from-microphone # 2. https:\/\/medium.com\/towards-data-science\/real-time-speech-recognition-python-assemblyai-13d35eeed226<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u0435\u043c, \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u043d\u0430 Python \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API AssemblyAI. \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0443 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f (\u0434\u0438\u043a\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0430\u0442\u044c\u0438\/\u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u0438\u0441\u044c\u043c\u0430, \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043d\u0430\u0432\u044b\u043a\u043e\u0432 \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439 \u0441 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0445\u0430 \u0438 \u0442. \u0434.).<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u0436\u0435 \u0434\u043b\u044f \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0445 API. \u0410 \u043c\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_010622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_010622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e <a href=\"https:\/\/skillfactory.ru\/concalogue?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=sf_allcourses_010622&amp;utm_term=conc\">\u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e<\/a>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/skillfactory\/blog\/669126\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/669126\/<\/a><br \/><\/br><\/br><\/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-333931","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333931","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=333931"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333931\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}